const arr = [0,1,1,1,2,3] const set = new Set([...arr]) console.log(set)
Sets are great to keep track of active Filter Badges or of loading / fetching states when making requests to external data sources.
Adds an entry in a Set and takes the entry as argument
Removes a specified entry from the Set
Returns a boolean depending on the value existing or not in the Set
- How can you get the size / length of a set?
.size property returns the amount of unique elements of each Set.
- How is the performance compared to an array?