Skip to content
Related Articles

Related Articles

Node.js urlSearchParams.values()

View Discussion
Improve Article
Save Article
  • Last Updated : 14 Oct, 2021
View Discussion
Improve Article
Save Article

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




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


Output:

valueA
valueB

Example 2: To create parameters directly




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


Output:

deepak
18

Supported Browsers:

  • Google Chrome
  • IE
  • Edge
  • Opera
  • Apple Safari
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!