Weak Maps

weak maps and their behavior in Javascript

Weak maps have object keys, and arbitrary values. When all strong references to a key are removed, the key is garbage collected, and the key-value pair is removed from the weak map.

Only the keys of weak maps are weak. Values placed in a weak map have strong references in the map.

Consider the following code:

Get hands-on with 1400+ tech skills courses.