![]() |
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:
FAQs – JavaScript Set keys() MethodCan the iterator returned by Set.keys() be used in a for…of loop?
Does Set.keys() preserve the insertion order of elements?
What happens if you modify the Set while iterating with Set.keys()?
Can Set.keys() be used on other collection types?
What is the result of calling Set.keys() on an empty Set?
|
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |