JavaScript(ES6) WeakMap garbage collection when set an object to null
I've just read that WeakMaps take advantage of garbage collection by working exclusively with objects as keys, and that assigning an object to null is equivalent to delete it: let planet1 = {name: 'Coruscant', city: 'Galactic City'}; let planet2 = {name: 'Tatooine', city: 'Mos Eisley'}; let planet3 = {name: 'Kashyyyk', city: 'Rwookrrorro'}; const lore = new WeakMap(); lore.set(planet1, true); lore.set(planet2, true); lore.set(planet3, true); console.log(lore); // output: WeakMap {{…} => true, {…} => true, {…} => true} Then I set the object equal to null: planet1 = null; console.log(lore); //