A short-hand way to do it is to convert it to an array via the ES6 spread operator.

Then all the array functions are available to you.

const mySet = new Set([1,2,3,4]);
[...mySet].reduce(...);
Answer from ZephDavies on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map › set
Map.prototype.set() - JavaScript - MDN Web Docs - Mozilla
September 7, 2026 - The set() method of Map instances adds a new entry with a specified key and value to this Map, or updates an existing entry if the key already exists.
People also ask

How is a Set different from a Map in JavaScript?

A Set stores unique values, whereas a Map stores key-value pairs. Discover their differences in the Free JavaScript map set tutorial for beginners.

🌐
iqratechnology.com
iqratechnology.com › academy › javascript-training › js-map-set
Free JavaScript Map Set Tutorial for Beginners - JS Map & Set.
What is the purpose of a Map in JavaScript?

A Map object stores key-value pairs and allows keys of any data type, offering more flexibility than regular objects. Learn more in our JavaScript map set free course video.

🌐
iqratechnology.com
iqratechnology.com › academy › javascript-training › js-map-set
Free JavaScript Map Set Tutorial for Beginners - JS Map & Set.
Are Map and Set better than regular objects and arrays?
  • Use Map when you need key-value pairs with non-string keys.
  • Use Set for storing unique values without duplicates.
    Find helpful insights in the JavaScript map set free course video.
🌐
iqratechnology.com
iqratechnology.com › academy › javascript-training › js-map-set
Free JavaScript Map Set Tutorial for Beginners - JS Map & Set.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Map and Set
... Although map[key] also works, e.g. we can set map[key] = 2, this is treating map as a plain JavaScript object, so it implies all corresponding limitations (only string/symbol keys and so on).
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-map-set-method
JavaScript Map set() Method - GeeksforGeeks
June 1, 2026 - The JavaScript map.set() method is used to add key-value pairs to a Map object. It can also be used to update the value of an existing key.
🌐
W3Schools
w3schools.com › js › js_maps.asp
JavaScript Maps
You can add elements to a Map with the set() method: ... Map is an ES6 feature. ES6 is fully supported in all modern browsers since June 2017: ... Coding fundamentals as bite-sized lessons and challenges.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map
Map - JavaScript - MDN Web Docs - Mozilla
August 13, 2026 - A Map object is iterated by key-value pairs — a for...of loop returns a 2-member array of [key, value] for each iteration. Iteration happens in insertion order, which corresponds to the order in which each key-value pair was first inserted into the map by the set() method (that is, there wasn't a key with the same value already in the map when set() was called).
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › set-and-map-in-javascript
How to Use Set and Map in JavaScript
February 10, 2023 - Some of the characteristics of sets are that the order of elements is not guaranteed, you can't access elements by index, and you can't have duplicate elements. Sets are a great choice when you want to store data without duplicates. A map is another data structure/container used to store key-value pairs of data of any kind and length.
🌐
Iqra Technology
iqratechnology.com › academy › javascript-training › js-map-set
Free JavaScript Map Set Tutorial for Beginners - JS Map & Set.
April 24, 2025 - A Map object stores key-value pairs ... more in our JavaScript map set free course video. ... Use the new Map() constructor and the set() method to add key-value pairs....
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-a-set-to-map-in-javascript
How to convert a Set to Map in JavaScript? - GeeksforGeeks
July 23, 2025 - The Array.from() method can be used to convert a Set to a Map by passing the Map and a callback function to set the keys and the values of the Map as parameters to this method.
🌐
Codecademy
codecademy.com › docs › javascript › map › .set()
JavaScript | Map | .set() | Codecademy
March 11, 2024 - Key-value pairs are stored in a Map object using the .set() method. ... The example above uses .set() to store two entries in the fruits map: one for 5 apples and another for 8 oranges.
🌐
Educative
educative.io › blog › javascript-map-set
JavaScript map and set tutorial: How to use new built-in classes
The need for map and set in ES6What is a map in JavaScript?Key characteristics of a map in JavaScriptMap vs object in Javascript: Key differencesHow to implement a mapUtilizing maps in JavaScriptIterating through a mapInitialize a map with an iterable objectGet an element from a map by keyGet the number of elements in the mapConvert map keys or values to arrayOther important map methodsHands-on exercise with mapSolution breakdownWhat is set in JavaScript?Key characteristics of a set in JavascriptSet vs array: Key differencesWorking with set: Methods and examplesfilter/map with setsGet the size
🌐
freeCodeCamp
freecodecamp.org › news › javascript-map-and-set-objects-explained
How to Use the JavaScript Map and Set Objects – Explained with Code Examples
February 21, 2024 - You would create an object and convert it into a JSON string, so using a Map object won't give any benefit. The Set object allows you to store a collection of elements, just like an Array.
🌐
Tania's Website
taniarascia.com › understanding-map-and-set-javascript
Understanding Map and Set in JavaScript | Tania Rascia's Website
February 12, 2020 - Developers use Objects to store key/value pairs and Arrays to store indexed lists. However, to give developers more flexibility, the ECMAScript 2015 specification introduced two new types of iterable objects: Maps, which are ordered collections of key/value pairs, and Sets, which are collections of unique values.
🌐
DEV Community
dev.to › rasaf_ibrahim › set-and-map-in-javascript-a-close-look-h01
Set and Map in JavaScript: A Close Look - DEV Community
November 8, 2023 - A Map directly provides the size property, making it easy to determine the number of key-value pairs. With an Object, we would typically use Object.keys(obj).length, which is less direct. ... For frequent additions and removals of key-value pairs, Map is more performant than using an Object. Both Set and Map are robust constructs in JavaScript that can greatly enhance the way we work with collections of data.
🌐
DigitalOcean
digitalocean.com › community › tutorials › understanding-map-and-set-objects-in-javascript
Understanding Map and Set Objects in JavaScript | DigitalOcean
Introduced in ECMAScript 2015, Maps in JavaScript are ordered collections of key/value pairs, and Sets are collections of unique values. In this article, you…
🌐
Medium
mattburgess.medium.com › javascript-shinies-map-set-and-symbol-11bc4f0d2fbf
Javascript Shinies: Map, Set and Symbol | by Matt Burgess | Medium
April 9, 2025 - Well, the difference mostly comes up when the array or set is being used to check if we have a particular value already. When you do a check on an array using array.includes, JavaScript loops through the array to look for that value. On a large array that can be a lot.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › set-vs-map-in-javascript
Set Vs Map in JavaScript - GeeksforGeeks
In JavaScript, Set and Map are built-in data structures used to store ordered collections of data, where Set holds unique values and Map stores data as key–value pairs.
Published: January 16, 2026
🌐
TechRepublic
techrepublic.com › home › devops
JavaScript Map and Set Tutorial
November 4, 2023 - Here’s an example: ... The Map object in JavaScript provides several key methods for adding, retrieving and manipulating key-value pairs. The set() method is used to add or update a key-value pair in a Map.