Open In App

Node.js urlSearchParams.values()

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().






// Create a test URLSearchParams object
const searchParams = new URLSearchParams("keyA=valueA&keyB=valueB");
 
// Display the values
for(let value of searchParams.values()) {
      console.log(value);
}

Output:

valueA
valueB

Example 2: To create parameters directly 




// Create a test URLSearchParams object
const searchParams = new URLSearchParams("name = deepak &  age = 18 ");
 
// Display the values
for (let value of searchParams.values()) {
    console.log(value);
}

Output:

deepak
18

Supported Browsers:

Article Tags :