Yogesh Chauhan's Blog

12 URLSearchParams methods in JavaScript

in JavaScript on February 7, 2021

1. append()

This method appends a specified key/value pair in URL query string (appends at the end).

2. delete()

This method deletes the specified search parameter and all its associated values.

3. entries()

This method returns an iterator that allows iteration through all key/value pairs in the object.

4. forEach()

This method allows iteration as well but via a callback function.

5. get()

This method returns the value related to the defined search parameter but only the first matched value.

6. getAll()

This method returns ALL the values related to the defined search parameter.

7. has()

This method returns true if the parameter with the specified name exists and false if it doesn’t exist.

8. keys()

This methods allows to iterate over the object as well but it only allows iteration through keys.

9. set()

This method changes the value related to the search parameter to the provided value.

If there are multiple matching values, it will delete the other values.

It will create the search parameter if it doesn’t exist.

10. sort()

This method sorts all key/value pairs as per the unicode code points of the keys.

This method will maintain the relative order between key/value pairs with equal keys.

11. toString()

This method returns a query string.

12. values()

This is opposite to the keys() method. This methods allows to iterate over the object through values.

Source: MDN


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to check if the page is the home page in WordPress?WordPressHow to check if checkbox is checked or not using JavaScript?JavaScriptJavaScript Number MethodsJavaScriptHow to create Flickering Texts using CSS?CSSHow JavaScript classes allows us to do less typing (syntactic sugar)?JavaScriptWhat are Conditional Tags in WordPress?WordPress