Callbacks & Callback Hell
What callback protection does this utility provide?
function once(fn) {
let called = false;
return function(...args) {
if (called) return;
called = true;
fn.apply(this, args);
};
}
function once(fn) {
let called = false;
return function(...args) {
if (called) return;
called = true;
fn.apply(this, args);
};
}