Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScriptclosures and memory retentionSingle-choice MCQ

Why can a single small closure unexpectedly retain a large object in V8, causing a leak?

function makeGetter() { const huge = new Array(1e6).fill('x'); const tiny = 42; return () => tiny; } const get = makeGetter();