Open In App

JavaScript Set values() Method

Last Updated : 12 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Share
2 Likes
Like
Report

The Set.values() method in JavaScript returns a new Iterator object that contains all of the items available in the set in a certain order. The order of values are in the same order that they were inserted into the set.

Syntax:

mySet.values()

Parameters:

  • This method does not accept any parameters.

Return Value:

  • The Set.values() method returns a new iterator object which holds the values for each element present in the set.

The below examples illustrate the Set.values() method:

Example 1:

Output:

California
Seattle
Chicago

Example 2:

Output:

California
Seattle
Chicago

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

Similar Reads