![]() |
VOOZH | about |
The Set.entries() method returns a new Iterator object that contains an array of [value, value] for each element in the Set object, in the order of their insertion. Although a Set does not contain key-value pairs, to keep similarities with the map.entries() method, it will return key-value pairs where both key and value will have the same value.
Syntax:
mySet.entries()Parameters: This method does not accept any parameters.
Return Value: The entries() method returns a new Iterator object that contains an array of [value, value] for each element in the Set object, in insertion order.
Example 1:
Output:
[ 'California', 'California' ]
[ 'Seattle', 'Seattle' ]
[ 'Chicago', 'Chicago' ]
Example 2:
Output:
[ 'California', 'California' ]
[ 'Seattle', 'Seattle' ]
[ 'Chicago', 'Chicago' ]
Supported Browsers:
We have a complete list of Javascript Set methods, to check those please go through this Sets in JavaScript article.
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through