Node | URLSearchParams.keys()
In URLSearchParams interface, the keys() method returns an Iterator which allows us to iterate through all the keys present in the object.
Syntax:
searchParams.keys();
Return:Returns an ES6 Iterator over the names of each name-value pair.
Example 1:
var searchParams = new URLSearchParams("keyA=valueA&keyB;=valueB"); // Display the key/value pairs for(var key of searchParams.keys()) { console.log(key); } |
chevron_right
filter_none
Output:
keyA keyB
Example2:
var searchParams = new URLSearchParams("name=john&age;=18"); // Display the key/value pairs for(var key of searchParams.keys()) { console.log(key); } |
chevron_right
filter_none
Output:
name age
Supported Browsers:
- Google Chrome
- IE
- Edge
- Opera
- Apple Safari
Recommended Posts:
- 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
- Routing in Node.js
- Node | URL.host API
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.



