blob: e7b812241b8dc6589892c592fb2c86e3bf92c443 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
---
title: URLSearchParams.entries()
slug: Web/API/URLSearchParams/entries
translation_of: Web/API/URLSearchParams/entries
---
{{APIRef("URL API")}}{{SeeCompatTable}}
La méthode **`URLSearchParams.entries()`** retourne un itérateur( {{jsxref("Iteration_protocols",'iterator')}}) permettant de parcourir les paires de clé/valeur contenues dans cet objet. La clé et la valeur de chaque paire est un objet {{domxref("USVString")}} .
> **Note :** This method is available in [Web Workers](/en-US/docs/Web/API/Web_Workers_API).
## Syntax
searchParams.entries();
### Return value
Returns an {{jsxref("Iteration_protocols","iterator")}}.
## Example
```js
// Create a test URLSearchParams object
var searchParams = new URLSearchParams("key1=value1&key2=value2");
// Display the key/value pairs
for(var pair of searchParams.entries()) {
console.log(pair[0]+ ', '+ pair[1]);
}
```
The result is:
key1, value1
key2, value2
## Specifications
| Specification | Status | Comment |
| ------------------------------------------------------------------------------------------------ | -------------------- | ------------------ |
| {{SpecName('URL', '#urlsearchparams','entries() (as iterator<>)')}} | {{Spec2('URL')}} | Initial definition |
## Browser compatibility
{{Compat("api.URLSearchParams.entries")}}
## See also
- Other URL-related interfaces: {{domxref("URL")}}, {{domxref("URLUtils")}}.
|