Fish Touching🐟🎣

JavaScript WeakMap

Apr 3, 2023

WeakMap - JavaScript | MDN

# What is WeakMap

WeakMap is a collection of key/value pairs whose keys must be objects, with values of any arbitrary  JavaScript type, and which does not create strong references to its keys.
That is, an object’s presence as a key in a WeakMap does not prevent the object from being garbage collected. Once an object used as a key has been collected, its corresponding values in any WeakMap become candidates for garbage collection as well — as long as they aren’t strongly referred to elsewhere.

# Why use WeakMap