Skip to content

JavaScript set entries() Method

  • by

JavaScript set entries() Method used to return a new Iterator object that contains an array of key-value pairs for each element in the Set object, in insertion order.


Note: The set does not contain key-value pairs, to keep similarities with the map entries() method, it will return key-value pairs with the same value.

JavaScript set entries() examples

Simple example code.

<!DOCTYPE html>
  <script >
    const mySet = new Set(["apple", "banana", "orange"]);

    const setIterator = mySet.entries();

    for (const entry of setIterator) {



JavaScript set entries() Method

You can also use the spread operator (...) to convert the iterator to an array of key-value pairs:

const mySet = new Set(["apple", "banana", "orange"]);

const entriesArray = [...mySet.entries()];


Do comment if you have any doubts or suggestions on this Js set method topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading