Node.js URLSearchParams.keys()
Last Updated :
14 Oct, 2021
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" );
for ( var key of searchParams.keys()) {
console.log(key);
}
|
Output:
keyA
keyB
Example2:
var searchParams = new URLSearchParams( "name=john&age=18" );
for ( var key of searchParams.keys()) {
console.log(key);
}
|
Output:
name
age
Supported Browsers:
- Google Chrome
- IE
- Edge
- Opera
- Apple Safari
Share your thoughts in the comments
Please Login to comment...