Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScriptgarbage collection and leaksSingle-choice MCQ

A WeakMap is used to attach metadata to DOM nodes. Why does a WeakMap entry NOT keep its key alive, and what is the precise reachability rule the GC applies to WeakMap entries?

const meta = new WeakMap(); function tag(node) { meta.set(node, { seen: Date.now() }); }