Skip to content
Advertisement

Why url query component is not removed?

I wrap the href to URL, and try to remove one component, remove with delete, but component does not disappear. Do you know why?

JavaScript

I tried this:

JavaScript

but it says

Uncaught TypeError: url.searchParams.filter is not a function


I tried now this expression, but filter does not work, do you have any idea why?

JavaScript

Advertisement

Answer

The delete operator deletes properties from objects.

You are trying to delete a variable. This fails silently.

To delete something from a URLSearchParams object, use the delete method:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement