Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptclosures as a patternSingle-choice MCQ

What does this once-wrapper return on its second and third invocation?

function once(fn) { let called = false, result; return function (...args) { if (!called) { called = true; result = fn.apply(this, args); } return result; }; } const init = once(() => ({ id: Math.random() })); const a = init(), b = init(); console.log(a === b);