Node | URLSearchParams.forEach()
In URLSearchParams interface, the foreach() method returns an iterator which allows to iterate through all values contained in this object with the help of a callback function.
Syntax:
searchParams.forEach(callback);
Return: It does not return anything, used for invoking the function and iteraating through it.
Parameters:
callback – Input the callback function that wil be executed against each parameter, with the value of the parameter provided as its parameter.
Example1:
// Create a test URLSearchParams object // Log the values myURL.searchParams.forEach(function(value, key) { console.log(value, key); }); |
Output:
vala keya valb keyb
Example2:
// Create a test URLSearchParams object // Log the values myURL.searchParams.forEach(function(value, key) { console.log(key,value); }); |
Output:
par parval foo fooval bar barval
Supported Browsers:
- Google Chrome
- IE
- Edge
- Opera
- Apple Safari
Recommended Posts:
- Node.js | NPM (Node Package Manager)
- PHP vs. Node.js
- Node js | OS
- Why Node.js ?
- Node | URL.hash API
- Node.js Events
- Node | URLSearchParams.set()
- Node | URL.fileURLToPath API
- Node | URL.resolve(from,to) API
- Node | URLSearchParams.has()
- HTTPS in Node
- Node | URL.pathToFileURL API
- Node | URL.domainToASCII
- Node | URL.protocol API
- Node.js | pop() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



