WeakMap

A key-value collection whose keys must be objects and are held weakly, so an entry disappears when its key object is garbage collected.

In more detail

It is ideal for attaching metadata to DOM elements: when the element is removed and forgotten, its data goes too. To make this possible WeakMap cannot be iterated and has no size. Keys can be objects or non-registered symbols.

Related terms

Taught in

References