Lesson 24. Sets
After reading lesson 24, you will
- Know how to use and create sets
- Know how to perform array operations on sets
- Understand when to use arrays and when to use sets
- Understand what WeakSets are and when to use them
Sets are a new type of object in JavaScript. A set is a unique collection of data. It can store any data type but won’t store duplicate references to the same value. Sets are iterables, so you can use spread and for..of with them. Sets are most closely related to arrays; however, when you use an array your focus is generally on the individual items in the array. When dealing with a set, you’re usually dealing with the set as a whole.
Imagine you’re building a video game where the player starts ...
Get Get Programming with JavaScript Next now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.