Node | URLSearchParams.has()
In URLSearchParams interface, the has() method returns a Boolean which tells us that if the parameter with input name exists it will return true, else false.
Syntax:
var Bool = URLSearchParams.has(name)
Returns: True – if name present, else it will return False.
Parameters:
name – Input the name of the parameter.
Example1:
let param = new URLSearchParams(url.search.slice(1)); param.has('bar') === true; |
chevron_right
filter_none
Output:
true
Example2: When input parameter is not present
let param = new URLSearchParams(url.search.slice(1)); param.has('foo') === true; |
chevron_right
filter_none
Output:
false
Supported Browsers:
- Google Chrome
- IE
- Edge
- Opera
- Apple Safari
Recommended Posts:
- Node.js | NPM (Node Package Manager)
- Why Node.js ?
- Node js | OS
- PHP vs. Node.js
- Node | URL.resolve(from,to) API
- Node | URL.pathToFileURL API
- Node | URL.protocol API
- Node | URL.fileURLToPath API
- Node | URL.hash API
- Routing in Node.js
- Node | URLSearchParams.set()
- Node | URL.domainToASCII
- Node | URLSearchParams.get()
- HTTPS in Node
- Node | URL.href 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.



