Back to search

Collections in JavaScript: Set, Map, WeakSet, and WeakMap

JavaScript has keyed and set-like collections beyond plain objects and arrays, including weak collections for object-keyed references.

JavaScript Medium Theory

Collections in JavaScript: Set, Map, WeakSet, and WeakMap

JavaScript has keyed and set-like collections beyond plain objects and arrays, including weak collections for object-keyed references.

  • Map preserves insertion order and allows any key type
  • Set stores unique values
  • Weak collections hold weak references to objects only

Collections in JavaScript: Set, Map, WeakSet, and WeakMap