WeakMap
A weak map is a map in which elements can be garbage-collected at any moment.
The exact timing in which elements can be garbage-collected is implementation-defined. Some implementations may allow garbage-collection of keys, some may allow garbage-collection of values, or some entirely different behavior.
This class expresses that an association between two values exists, but we may be capable of regenerating it if it disappears, or we simply don't have an important enough need for it to keep memory.
Unlike regular Map, this interface doesn't allow iteration. It is not possible to observe the contents of this map, since they are ever mutable and elements may disappear at any time. Some implementations may provide such observability features.
Obtain instances
The default implementation is available via the top-level WeakMap function. Other implementations are available in the algorithms
subpackage.
Functions
Attempts to find the value associated with key, returning defaultValue if none is found.