1.

What is the use of the Weakmap object in JavaScript?

Answer»

The WEAKMAP object is BASICALLY a collection of key or value pairs where the keys are weakly referenced. It provides a way for extending OBJECTS from the outside without meddling into the garbage collection.

Here are some use cases of Weakmap objects:
  • Maintaining private data about a SPECIFIC object while only GIVING access to people having a reference to the Map.
  • Safekeeping of data related to the library objects without making any changes to them or incurring any overhead.
  • Keeping of data related to the host objects such as DOM nodes in the browser.


Discussion

No Comment Found