Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Node.js URLSearchParams.entries()

  • Last Updated : 14 Oct, 2021

In URLSearchParams interface, the entries() method returns an iterator which allows to iterate through all the key/value pairs present in the object.The key/value are USVString objects.

Syntax:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

searchParams.entries();

Return:iterator, iterating over all key-value pairs.

Example 1:






// Create a test URLSearchParams object
var searchpar = new URLSearchParams("keya=vala&keyb=valb");
  
// Display the key/value pairs
for(var pair of searchpar.entries()) {
   console.log(pair[0]+ ', '+ pair[1]); 
}

Output:

keya, vala
keyb, valb

Example 2:




// Create a test URLSearchParams object
var searchpar = new URLSearchParams("par=parval&foo=fooval&bar=barval");
  
// Display the key/value pairs
for(var pair of searchpar.entries()) {
   console.log(pair[0]+ ', '+ pair[1]); 
}

Output:

par, parval
foo, fooval
bar, barval

Supported Browsers:

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

Start Your Coding Journey Now!