JavaScript uses garbage collection, so objects, that don't get referred to anymore, get killed.
If I do var a = {};
and then I do a = null;
, the object gets deleted, because the only reference (a) doesn't refer to it anymore.
Now what if we have 2 objects referring to each other, but no one else referring to them, do those get deleted?
example:
var a = {};
var b = {};
a.ref = b;
b.ref = a;
a = null;
b = null;
The 2 objects are technically dead, but they refer to each other. Will they get deleted by the garbage collector or is this code example a memory leak ?