JavaScript Map and Set

John Wolfe
2 min readJul 23, 2021

Today, I ran into the use of map and set in JavaScript. Although these are fairly basic JavaScript concepts, it had been awhile since I’d seen them in practice, so this is a quick refresher on these concepts.

Set

A set is a feature of JavaScript that like an object can store all different types of primitive and non-primitive values. One frequent use of a set in JavaScript is to remove duplicate values from an array. For example, the below:

const array1 = [ 1, 1, 2, 3, 4 ]const myset = new Set(array1)

--

--

John Wolfe

Software developer Tata Consultancy Services. React, Rails, and Java. Former content editor for @Quora and @inversedotcom. I live in Chicago, Illinois.