javascript React html

Wek Map :
A 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.
WeakMap allows associating data to objects in a way that doesn't prevent the key objects from being collected, even if the values reference the keys.



WeakMap methods
WeakMap.prototype.delete(key)

Removes any value associated to the key. WeakMap.prototype.has(key) will return false afterwards.
WeakMap.prototype.get(key)

Returns the value associated to the key, or undefined if there is none.
WeakMap.prototype.has(key)

Returns a Boolean asserting whether a value has been associated to the key in the WeakMap object or not.
WeakMap.prototype.set(key, value)

Sets the value for the key in the WeakMap object. Returns the WeakMap object.