JavaScript URLSearchParams values() Tutorial

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

JavaScript URLSearchParams values() Method

The `values()` method returns an iterator object that contains all the values of the target query.

So using this method, we can iterate through all the values of a query.

URLSearchParams values() Method Syntax:

searchParams.values();

URLSearchParams values() Method Parameter:

This method does not take an argument.

URLSearchParams values() Method Return Value:

The return value of this method is an iterator object that can be used to iterate through all the elements of the target query.

Example: using URLSearchParams values() method in JavaScript

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

for (const value of searchParams.values()){

    console.log(value);

}

Output:

John

Doe

Mars

Omid

 [email protected]
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies