← Week 4 — 22 / 24 →

ES6 New Features: Sets

A Set is a collection of unique values. Javascript will automatically remove duplicates when you add them to a Set.

let s = new Set();
s.add(1);
s.add(1);
s.add(2);
console.log(s);  // Set { 1, 2 }