Skip to content
Related Articles

Related Articles

Node | URLSearchParams.delete()
  • Last Updated : 29 May, 2019

In URLSearchParams interface, the delete() method deletes the parameter specified by user and all its associated values.

Syntax:

URLSearchParams.delete(name)

Parameters:
name – The name of the parameter to be deleted.

Example 1:




let params = new URLSearchParams(url.search.slice(1));
  
// Delete the par parameter.
params.delete('par');
console.log(url)

Output:



https://example.com?bar=2

Example 2:




let url = new URL('https://example.com?foo=1&par=3');
let params = new URLSearchParams(url.search.slice(1));
  
// Delete the foo parameter.
params.delete('foo');
console.log(url)

Output:

https://example.com?par=3

Supported Browsers:

  • Google Chrome
  • IE
  • Edge
  • Opera
  • Apple Safari
My Personal Notes arrow_drop_up
Recommended Articles
Page :