URLSearchParams.delete()

The delete() method of the URLSearchParams interface deletes the given search parameter and all its associated values, from the list of all search parameters.

Note: This feature is available in Web Workers

Syntax

URLSearchParams.delete(name)

Parameters

name

The name of the parameter to be deleted.

Return value

Void

Examples

let url = new URL('https://example.com?foo=1&bar=2&foo=3');
let params = new URLSearchParams(url.search);

// Delete the foo parameter.
params.delete('foo'); //Query string is now: 'bar=2'

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
delete
49
17
29
No
36
10.1
Removing a non-existent query parameter doesn't remove ? from the URL. See bug 193022.
49
49
29
36
10.3
Removing a non-existent query parameter doesn't remove ? from the URL. See bug 193022.
5.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/delete