Tuesday, November 19, 2024
Google search engine
HomeLanguagesJavascriptNode.js URLSearchParams.entries()

Node.js URLSearchParams.entries()

In the URLSearchParams interface, the entries() method returns an iterator that allows iterating through all the key/value pairs present in the object. The key/value is USVString objects. 

Syntax:

searchParams.entries();

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

Example 1: 

javascript




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


Output:

keya, vala
keyb, valb

Example 2: 

javascript




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


Output:

par, parval
foo, fooval
bar, barval

Supported Browsers:

  • Google Chrome
  • Firefox
  • Edge (partial)
  • Opera
  • Apple Safari
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments