Web APIs

URLSearchParams.has()

Try the free JavaScript compiler

Check for a parameter name, optionally requiring the supplied value too. Example console output: true false.

Formal Syntax & Structure

javascript syntaxjavascript
params.has(name[, value])

Parameters & Attributes

NameTypeDescription
namestringParameter name.
valuestringMatching value if specified.

Return Value

boolean

Whether a matching pair exists.

Working Example

Example Snippetjavascript
const p=new URLSearchParams("tag=a&tag=b"); console.log(p.has("tag","b"),p.has("tag","c"));
JavaScript Reference