JS TutorialLesson 22Free preview
JS Sets
This lesson is part of JavaScript · All levels
Summary
Sets are a collection of unique values, so storing double data is automatically discarded during manufacture or addition. The set provides methods add, delete, has, and clear, as well as the size property to determine the amount of content. Sets are very useful for eliminating duplication from an array and checking data membership quickly.
Key points
- Sets are created with new Set() and only store unique values
- Add, delete, check for existence, empty
- Size knows the number of elements, not the length
- New Set(array) is a quick way to remove duplicates from an array
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.