Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
Think of a Set as a VIP guest list where each person's name can only appear once! It's a collection that automatically removes duplicates. Perfect for storing unique values like unique IDs, tags, or email addresses.
[1, 2, 2, 3]. Sets automatically ensure uniqueness: {1, 2, 3}Each value can only appear once - duplicates are automatically ignored!
Check if a value exists instantly - faster than arrays!
Store numbers, strings, objects - anything! Each unique value counts.
add(value)Add a new value
delete(value)Remove a value
has(value)Check if value exists
sizeGet number of values
clear()Remove all values
forEach()Loop through values
The most common use case - get unique values
Add, check, and remove items from Set
Each value can only appear once - perfect for unique collections
has() is much faster than array includes()
Use [...set] to convert Set back to Array
Tags, IDs, visited pages, unique usernames