Open In App

Node.js urlSearchParams.values()

Last Updated : 30 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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




// 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 

javascript




// 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:

  • Google Chrome
  • IE
  • Edge
  • Opera
  • Apple Safari

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads