Garbage Collection: Object Properties

Let's say I have an object that contains other objects, such as

var obj = {
    '1': {...},
    '42': {...}
};

When it objgoes out of scope, are all nested objects destroyed implicitly or do I need to iterate over them deleteexplicitly?

+3
source share
1 answer

Yes, if no other help exists yet:

var obj = {
    '1': {...},
    '42': {...}
};


var save = obj['1'];

obj = null; 

After garbage collection and the assumption that no other links were created, the space for obj and obj ['42 '] will be restored, the saved value, of course, will be saved.

Mea culpa: delete obj , obj var. obj , , , delete . var, obj = null. , , , delete true false.

+3

All Articles