A common closure pattern is the "once" wrapper, which guarantees a function runs only a single time and caches its result. Given the implementation below, what does the second call to `init()` log?
function once(fn) {
let called = false;
let result;
return function (...args) {
if (!called) {
called = true;
result = fn.apply(this, args);
}
return result;
};
}
let counter = 0;
const init = once(() => ++counter);
console.log(init()); // first
console.log(init()); // second