Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptMap Set WeakMapSingle-choice MCQ

Why might this WeakMap-based cache not behave like a memory leak, and what is true about it?

let key = { id: 1 }; const wm = new WeakMap(); wm.set(key, 'cached'); console.log(wm.has(key)); key = null; // later, after GC