YogeshChauhan . com

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

amazon

Most Read

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

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

How to activate and deactivate hooks in a WordPress plugin?WordPressIN Operator in PostgreSQLPostgresHow to implement NSNumberFormatter in Swift for currency?SwiftFlash of Invisible Text and Mitt Romney Web Font ProblemCSSHow to replace HTML lists using CSS Counters?CSSIntroduction to components and templates Part 2: Templates and viewsAngular