I am writing code for JS. And I need to know how works memory in JS when I remove big Object.
var a = new Object();
a.b = new Object();
a.b.c = new Object();
a.b.c.d = new Object();
a.b = undefined; // Is it delete a.b.c and a.b.c.d or not?
I am writing code for JS. And I need to know how works memory in JS when I remove big Object.
var a = new Object();
a.b = new Object();
a.b.c = new Object();
a.b.c.d = new Object();
a.b = undefined; // Is it delete a.b.c and a.b.c.d or not?
JavaScript is automatically garbage collected; the object's memory will be reclaimed only if the Garbage Collectior decides to run and the object is eligible for that.
The delete operator or nullify your object ( a.b = undefined; )has nothing to do with directly freeing memory (it only does indirectly via breaking references). See the memory management page for more details).