Skip to content

Set

A Set is a collection of unique values — each value can only occur once. Sets can store any type (primitives and object references).

  • Create and manipulate Set collections
  • Use Set for array deduplication
  • Perform union, intersection, and difference operations
  • Understand WeakSet for memory-safe tracking
flowchart LR
A["Input: [1, 2, 2, 3, 3, 3]"]
B["new Set(input)"]
C["Set {1, 2, 3}"]
A --> B --> C
TopicDescriptionEst. Time
Set Methodsadd, has, delete, clear, size10 min
Set OperationsUnion, intersection, difference15 min
WeakSetGarbage-collectable Set10 min
  • Arrays and their methods
  • Basic understanding of collections
Set Methods → Set Operations → WeakSet