VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-set-keys-method/

⇱ JavaScript Set keys() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Set keys() Method

Last Updated : 23 Jul, 2025

The set.keys() method is the same as the values() method. This means it returns the new iterator object that contains the value of each set in the insertion order. 

Syntax:

keys()

Parameter: This method does not take any parameters.

Return Type: It returns the new iterator object which holds the values in the set.

Example 1: In this example, we will see the use of keys in the set.

Output:

[Set Iterator] { 'America', 'England', 'Chicago' }

Example 2: In this example, we will see the keys() method which returns the set iterator.


Output
[Set Iterator] { '0', 1 }

We have a complete list of Javascript Set methods, to check those please go through this Sets in JavaScript article.

Supported Browser:

  • Chrome 38
  • Edge 12
  • Firefox 24
  • Opera 25
  • Safari 8
Comment