The
urlSearchParams.keys() method is an inbuilt application programming interface of the
URLSearchParams class within
url module which is used to get the iterator object containing all the name entries only of URL search params object.
Syntax:
const urlSearchParams.keys()
Parameter: This method does not accept any parameter.
Return value: This method returns the iterator object containing all the name entries only of URL search params object.
Below programs illustrates the use of
urlSearchParams.keys() method in Node.js:
Example 1: Filename: app.js
Run
app.js file using the following command:
node app.js
Output:
list of all the keys
A
B
C
Example 2:
Filename: app.js
Run
app.js file using the following command:
node app.js
Output:
list of all the keys
G
F
G
Note: The above program will not run on online JavaScript and script editor.
Reference: https://nodejs.org/dist/latest-v14.x/docs/api/url.html#url_urlsearchparams_keys