YogeshChauhan.com
12 URLSearchParams methods in JavaScript
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

dreamhost

Leave a Reply

Most Read

#1 How to set opacity or transparency using CSS? #2 Pagination in CSS with multiple examples #3 How to check if radio button is checked or not using JavaScript? #4 How to make HTML form interactive and using CSS? #5 How to uninstall Cocoapods from the Mac OS? #6 How to add Read More Read Less Button using JavaScript?



Recently Posted

Feb 24 How to modify the latest post array using get_posts() in WordPress? Feb 22 WordPress: How to get ACF field values from another post? Feb 22 WordPress: How to print ACF repeater field values? Feb 22 WordPress: How to print ACF array field values? Feb 21 WordPress: How to get field values in Advanced Custom Fields? Feb 21 WordPress: How to add a Search Icon in Menus with toggle effect using jQuery?



You might also like these

What is the best way to add JavaScript Code into HTML?HTMLHow to add AppRoutingModule in Angular application using command line?AngularWhat is Host Hardening and What are some Important Hardening Steps?MiscHow to get Current Year, Month and Date in JavaScript?JavaScriptJavaScript Data Types and Data Structures Things to RememberJavaScriptIntroduction to components and templates Part 4: Pipes and DirectivesAngular