DEV Community

Discussion on: Weak References in JavaScript

Collapse
 
harshilparmar profile image
Harshil Parmar

Great !! this is something new for me 😍
Question : Map and {} use strong reference right ??

Collapse
 
justan0therdev profile image
Ruan Montelo

Hi Harshil,
Yes. A Map/Set structure should protect an object from being "Garbage Collected", unlike the WeakMap/Set structures. The same applies to a property of an object "{}". While the property is in use (is referenced), the whole object will still live in memory.

Collapse
 
harshilparmar profile image
Harshil Parmar

Thanks bro 😊