Tuesday, November 19, 2024
Google search engine
HomeLanguagesJavascriptNode.js URLSearchParams.has() Method

Node.js URLSearchParams.has() Method

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 url = new URL('https://example.com?par=5&bar=4');
let param = new URLSearchParams(url.search.slice(1));
  
param.has('bar') === true


Output:

true

Example2: When input parameter is not present




let url = new URL('https://example.com?par=5&bar=4');
let param = new URLSearchParams(url.search.slice(1));
  
param.has('foo') === true


Output:

false

Supported Browsers:

  • Google Chrome
  • IE
  • Edge
  • Opera
  • Apple Safari
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments