WeakRefs in JavaScript: Explained In Simple Terms
Understanding how WeakRef helps manage memory in JavaScript
Every time you create an object in JavaScript, it takes up memory in your browser. When you’re done with that object, JavaScript is supposed to clear that memory automatically. But sometimes, this cleanup doesn’t happen when you expect it to.
Strong References
A strong reference is like putting a “do not delete” tag on data in memory. When you create a normal variable in JavaScript that points to an object or value, you’re creating a strong reference.
As long as this reference exists, JavaScript’s garbage collector won’t remove that data from memory, even if it’s not being used anywhere else.
// Creates a strong reference to an object
const user = {
url: "www.trevorlasn.com" ,
name: "Trevor Lasn"
};
Here, the user variable strongly holds onto the object, keeping it safe from garbage collection.

