Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardNodeJSV8 garbage collectionSingle-choice MCQ

Why can a function-local object in a hot loop sometimes incur zero garbage-collection cost in V8, never appearing in the heap at all?

function dist(x, y) { const p = { x, y }; // does this hit the heap? return Math.sqrt(p.x * p.x + p.y * p.y); }