JavaScript Sets
A JavaScript Set is a collection of unique values. Each value can only occur once in a Set.
Creating a Set
You can create a Set from an array:
javascript
const letters = new Set(["a","b","c"]);Set Methods
add()- Adds a new element to the Set.delete()- Removes an element from a Set.has()- Returns true if a value exists in the Set.forEach()- Invokes a callback for each element.values()- Returns an iterator with all the values in a Set.
Test Yourself with an Exercise
What is the main characteristic of a JavaScript Set?