Set and WeakSet
Learn Set and WeakSet (Phase 6 · Array Methods, Map, Set (Essential), JavaScript) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Set: unique values • A Set stores each value at most once, keeps insertion order and checks membership in roughly constant time. • API: add , has , delete , clear , size ; iterate with for...of or spread. • The fastest way to remove duplicates: [...new Set(arr)] .