URLSearchParams
The URLSearchParams interface defines utility methods to work with the query string of a URL.
Methods
[iterator]()
iterator: URLSearchParamsIterator<[string, string]>;
Returns
URLSearchParamsIterator<[string, string]>
append()
append(name, value): void;
The append() method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
Parameters
| Parameter | Type |
|---|---|
name | string |
value | string |
Returns
void
delete()
delete(name, value?): void;
The delete() method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
Parameters
| Parameter | Type |
|---|---|
name | string |
value? | string |
Returns
void
entries()
entries(): URLSearchParamsIterator<[string, string]>;
Returns an array of key, value pairs for every entry in the search params.
Returns
URLSearchParamsIterator<[string, string]>
forEach()
forEach(callbackfn, thisArg?): void;
Parameters
| Parameter | Type |
|---|---|
callbackfn | (value, key, parent) => void |
thisArg? | any |
Returns
void
get()
get(name): string | null;
The get() method of the URLSearchParams interface returns the first value associated to the given search parameter.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
string | null
getAll()
getAll(name): string[];
The getAll() method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
string[]
has()
has(name, value?): boolean;
The has() method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
Parameters
| Parameter | Type |
|---|---|
name | string |
value? | string |
Returns
boolean
keys()
keys(): URLSearchParamsIterator<string>;
Returns a list of keys in the search params.
Returns
URLSearchParamsIterator<string>
set()
set(name, value): void;
The set() method of the URLSearchParams interface sets the value associated with a given search parameter to the given value. If there were several matching values, this method deletes the others. If the search parameter doesn't exist, this method creates it.
Parameters
| Parameter | Type |
|---|---|
name | string |
value | string |
Returns
void
sort()
sort(): void;
The URLSearchParams.sort() method sorts all key/value pairs contained in this object in place and returns undefined. Key/value pairs are sorted by the values of the UTF-16 code units of the keys. This method uses a stable sorting algorithm (i.e., the relative order between key/value pairs with equal keys will be preserved).
Returns
void
toString()
toString(): string;
Returns
string
values()
values(): URLSearchParamsIterator<string>;
Returns a list of values in the search params.
Returns
URLSearchParamsIterator<string>
Properties
size
readonly size: number;
The size read-only property of the URLSearchParams interface indicates the total number of search parameter entries.