Sets are a new object type with ES6 (ES2015) that allow creating collections of unique values. The values in a set can be either simple primitives like strings or integers as well as more complex object types like object literals or arrays.
Sets in JavaScript are similar to arrays, but they have unique elements. Since elements in sets are unique, they are helpful for converting arrays into “sets” of unique values. Sets come with their own respective methods.
The entries
method provides an abstraction to iterate over a data collection where you may potentially only care about the values.
Maps are another new object type introduced with ES6. Maps fix deficiencies in standard objects such as not having a size method or only allowing strings and symbols. Maps on the other hand, can hold any types as key value pairs. Furthermore, maps also know the original insertion order of the keys and can maintain order to iterate through.
If you’d like to get started with writing your own maps and sets, here’s the syntax for how you’d start it.
If you’d like to learn more, here are some of the resources I used to learn these concepts.