class
URLSearchParams
class URLSearchParams
- name: string,value: string): void;
Appends a specified key/value pair as a new search parameter.
- name: string,value?: string): void;
Deletes the given search parameter, and its associated value, from the list of all search parameters.
Returns an array of key, value pairs for every entry in the search params.
- thisArg?: any): void;
Iterates over each name-value pair in the query and invokes the given function.
const myURL = new URL('https://example.org/?a=b&c=d'); myURL.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURL.searchParams === searchParams); }); // Prints: // a b true // c d true
@param callbackfnInvoked for each name-value pair in the query
@param thisArgTo be used as
this
value for whenfn
is called - name: string): string[];
Returns all the values association with a given search parameter.
- has(name: string,value?: string): boolean;
Returns a Boolean indicating if such a search parameter exists.
Returns a list of keys in the search params.
- set(name: string,value: string): void;
Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
Returns a string containing a query string suitable for use in a URL. Does not include the question mark.
Returns a list of values in the search params.