Node.js urlSearchParams.values()
Last Updated :
30 Mar, 2023
In the URLSearchParams interface, the values() method returns an iterator which allows us to iterate through all the values present in the object
Syntax:
searchParams.values();
Return: Returns an ES6 Iterator over the values of each name-value pair.
Example 1: In this example, we will see the use of urlSearchParams.values().
javascript
const searchParams = new URLSearchParams( "keyA=valueA&keyB=valueB" );
for (let value of searchParams.values()) {
console.log(value);
}
|
Output:
valueA
valueB
Example 2: To create parameters directly
javascript
const searchParams = new URLSearchParams( "name = deepak & age = 18 " );
for (let value of searchParams.values()) {
console.log(value);
}
|
Output:
deepak
18
Supported Browsers:
- Google Chrome
- IE
- Edge
- Opera
- Apple Safari
Share your thoughts in the comments
Please Login to comment...