URL

URLSearchParams.has()

Checks for a parameter name, optionally requiring a matching value. Tested on Node.js 22.16.0. The optional value form is supported on the tested release; verify compatibility for older runtimes.

Formal Syntax & Structure

nodejs syntaxnodejs
params.has(name[, value])

Parameters & Attributes

NameTypeDescription
namestringParameter name.
valuestringOptional exact value.

Return Value

boolean

Whether a matching pair exists.

Working Example

Example Snippetnodejs
import { URL, URLSearchParams, fileURLToPath, pathToFileURL } from 'node:url';const p=new URLSearchParams('tag=a&tag=b');console.log(p.has('tag','b'),p.has('tag','c'));
Node.js Reference