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 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#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 #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
Use SwiperJS to create mobile touch sliders fastMiscellaneousHow to Install PHP composer in Mac OS Catalina?PHPHow to Use SQL MAX() Function with Dates?SQL/MySQLOptional arguments, Default parameters and REST parameters in JavaScriptJavaScriptHow to create a simple text and image slider using CSS and JavaScript?CSSObject destructuring in JavaScript: Unpacking fields from objects passed as function parameterJavaScript