Sets and Maps

ES2015 added keyed collections: a Set holds unique values and a Map maps keys of any type to values. Both compare with SameValueZero (===, except that NaN equals NaN), iterate in insertion order and have a size. The specification requires sublinear average access times, so has() and get() stay fast where array.includes() scans every element. V8 86,723 implements all four collections, including WeakSet and WeakMap, as hash tables.

Subsections