Weak Maps
weak maps and their behavior in Javascript
Weak maps have object keys, and arbitrary values. When all strong references to a key are removed, the key is garbage collected, and the key-value pair is removed from the weak map.
Only the keys of weak maps are weak. Values placed in a weak map have strong references in the map.
Consider the following code:
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.