If I have an object that contains 2 sub-objects, and I delete the pointers to the parent object and one of the child objects, but I still have a pointer to the other child object, will JavaScript delete the one child and the parent, or will the whole parent object remain even though it’s no longer addressable?
I know I could use delete to remove the other child element, but that still leaves the parent. And I want to understand GC better and whether this explicit cleanup is necessary.
var parentObj = {
A: { subObjA: 'data' },
B: { subObjB: 'data' }
};
var persist = parentObj.B;
parentObj = null;
After this, will the parent object and subObjA be deleted since they are no longer accessible. or will the whole object remain because I have a pointer to subObjB?