JavaScript URLSearchParams entries() Tutorial

In this section, we will learn what the entries() method is and how to use it in JavaScript.

JavaScript URLSearchParams entries() Method

The `entries()` method is used to return an iterator object which contains all the key/value pairs of the target query. With this iterator object, then we can read all the elements (key/value pairs) of the target query.

URLSearchParams entries() Method Syntax:


URLSearchParams entries() Method Parameter:

The method does not take an argument.

URLSearchParams entries() Method Return Value:

The returned value of this method is an iterator that allows us to iterate through all the entries (key/value pairs) of the target query.

Example: using URLSearchParams entries() method in JavaScript

const searchParams = new URLSearchParams("?name=John&lastName=Doe&address=Mars&name=Omid");

for (const [key, value] of searchParams.entries()){

    console.log(`The key is: ${key} and the value is: ${value}`);



The key is: name and the value is: John

The key is: lastName and the value is: Doe

The key is: address and the value is: Mars

 The key is: name and the value is: Omid

Top Technologies