JavaScript WeakMap

JavaScript WeakMap object is used to store the elements as key-value pair where keys are weakly referenced.


new WeakMap([iterable])

Where: iterable is the object whose elements are in the form of key-value pair.

Note: WeakMap object can not contains the primitive type elements. It can contains only object type elements.

JavaScript WeakMap Methods:

Use: To delete the specified element from a WeakMap object.

Use: To return the value of specified key.

Use: To indicate whether the Weakmap object contains the specified value element.

Use: To add or update the key-value pairs to WeakMap object.

Please Share