{{ApiRef("URL API")}}{{SeeCompatTable}}
The has() method of the {{domxref("URLSearchParams")}} interface returns a {{jsxref("Boolean")}} that indicates whether a parameter with the specified name exists.
Syntax
var hasName = URLSearchParams.has(name)
Parameters
- name
- The name of the parameter to find.
Returns
A {{jsxref("Boolean")}}.
Example
let url = new URL('https://example.com?foo=1&bar=2'); let params = new URLSearchParams(url.search.slice(1)); params.has('bar') === true; //true
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('URL', '#dom-urlsearchparams-has', "has()")}} | {{Spec2('URL')}} | Initial definition. |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(49.0)}} |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatChrome(49.0)}} | {{CompatChrome(49.0)}} |