Loading problem…
Implement a once function that ensures a function is only executed once, regardless of how many times it's called.
fnfnfn only on the first callconst initialize = () => {
console.log('Initialized');
return 'setup complete';
};
const initializeOnce = once(initialize);
initializeOnce(); // Logs 'Initialized', returns 'setup complete'
initializeOnce(); // Returns 'setup complete' (no log)
initializeOnce(); // Returns 'setup complete' (no log)