Node.js URLSearchParams.entries()
In the URLSearchParams interface, the entries() method returns an iterator that allows iterating through all the key/value pairs present in the object. The key/value is USVString objects.
Syntax:
searchParams.entries();
Return: Iterator, iterating over all key-value pairs.
Example 1:
javascript
const searchpar = new URLSearchParams( "keya = vala&keyb = valb" );
for (let pair of searchpar.entries()) {
console.log(pair[0] + ', ' + pair[1]);
}
|
Output:
keya, vala
keyb, valb
Example 2:
javascript
const searchpar = new URLSearchParams( "par = parval & foo = fooval & bar = barval" );
for (let pair of searchpar.entries()) {
console.log(pair[0] + ', ' + pair[1]);
}
|
Output:
par, parval
foo, fooval
bar, barval
Supported Browsers:
- Google Chrome
- Firefox
- Edge (partial)
- Opera
- Apple Safari
Last Updated :
31 Mar, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...