tencent cloud

URLSearchParams.has
Last updated: 2025-03-10 17:23:45
URLSearchParams.has
Last updated: 2025-03-10 17:23:45
URLSearchParams.has is used to check whether the search parameter for the key exists.
has(key: string): boolean

Parameters

Parameter
Type
Description
key
string
Key.

Return

Type
Description
boolean
Whether the search parameter for the key exists.

Samples

Check whether the search parameter for the key exists:
import url from 'pts/url';

export default function() {
const params = new url.URLSearchParams('key1=value1&key2=value2');

console.log(params.has('key1')); // true
console.log(params.has('key3')); // false
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback