JavaScript WeakMap object is used to store the elements as key-value pairs where keys are weakly referenced.
Syntax:
new WeakMap([iterable])
Where: iterable is the object whose elements are in the form of a key-value pair.
Note: WeakMap object can not contain the primitive type elements. It can contain only object-type elements.
JavaScript WeakMap Methods:
delete()
Use: To delete the specified element from a WeakMap object.
get()
Use: To return the value of specified key.
has()
Use: To indicate whether the Weakmap object contains the specified value element.
set()
Use: To add or update the key-value pairs to WeakMap object.