I will make another topic but shortly, the memory of the Heap (where object are living and stored) is handled by garbage collector.
When you create an object you store the reference in this variable, but if you change this variable, you lost the reference into this object, so there is no access for it! And the garbage collector will delete this object.
A quick example
leta={toto:'hello'}letb=a// Both variable store the reference of { toto: 'hello' }a=55// b is the only variable that keep the reference of the objectb=60// There is no variable that keep this reference, so the Garbage collector will delete the object
I will make another topic but shortly, the memory of the Heap (where object are living and stored) is handled by garbage collector.
When you create an object you store the reference in this variable, but if you change this variable, you lost the reference into this object, so there is no access for it! And the garbage collector will delete this object.
A quick example
Thanks I understand it, js is really a smart language.