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

A closure captures a variable that is never read after the closure is created, only the closure object is retained long-term. Under V8's optimizing compiler, what determines whether that captured variable's value is actually kept alive on the heap?

function make() { const big = new Array(1e6).fill(0); const small = 42; return function () { return small; }; } const f = make();