class URLSearchParams
Supported only in the v8 engine. Introduced in Max v9.2.0.
Reads and manipulates URL query strings.
Example
const params = new URLSearchParams("a=1&b=2");
params.append("a", "3");
post(params.getAll("a").join(","), "\n"); // 1,3
post(params.toString(), "\n"); // a=1&b=2&a=3
Index
Constructors
Methods
- append(name, value)
- delete(name)
- entries()
- get(name)
- getAll(name)
- has(name)
- keys()
- set(name, value)
- toString()
- values()
new URLSearchParams(init)
new URLSearchParams(
init?: string | URLSearchParams | string[][] | Record<string, string>,
);
Constructs a new instance of the URLSearchParams class
| Parameter | Type | Description |
|---|---|---|
| optional init | string | URLSearchParams | string[][] | Record<string, string> | initial values: a query string, another URLSearchParams, an array of [name, value] pairs, or a record of string values. |
append(name, value)
Appends a new name/value pair.
append(name: string, value: string): void;
| Name | Type | Description |
|---|---|---|
| name | string | |
| value | string |
delete(name)
Removes all values for a name.
delete(name: string): void;
| Name | Type | Description |
|---|---|---|
| name | string |
entries()
Iterates [name, value] pairs.
entries(): IterableIterator<[string, string]>;
| Name | Type | Description |
|---|---|---|
| Return Value | IterableIterator<[string, string]> |
get(name)
Returns the first value for a name, or null.
get(name: string): string | null;
| Name | Type | Description |
|---|---|---|
| name | string | |
| Return Value | string | null |
getAll(name)
Returns all values for a name.
getAll(name: string): string[];
| Name | Type | Description |
|---|---|---|
| name | string | |
| Return Value | string[] |
has(name)
Returns whether any value exists for a name.
has(name: string): boolean;
| Name | Type | Description |
|---|---|---|
| name | string | |
| Return Value | boolean |
keys()
Iterates parameter names.
keys(): IterableIterator<string>;
| Name | Type | Description |
|---|---|---|
| Return Value | IterableIterator<string> |
set(name, value)
Sets a name to a single value, replacing any existing values.
set(name: string, value: string): void;
| Name | Type | Description |
|---|---|---|
| name | string | |
| value | string |
toString()
Serializes the parameters to a query string (without a leading ?).
toString(): string;
| Name | Type | Description |
|---|---|---|
| Return Value | string |
values()
Iterates parameter values.
values(): IterableIterator<string>;
| Name | Type | Description |
|---|---|---|
| Return Value | IterableIterator<string> |