Skip to content

Instantly share code, notes, and snippets.

@leegeunhyeok
Created October 8, 2020 05:23
Show Gist options
  • Save leegeunhyeok/e232887a4b8e549ac25386377c7ca104 to your computer and use it in GitHub Desktop.
Save leegeunhyeok/e232887a4b8e549ac25386377c7ca104 to your computer and use it in GitHub Desktop.
Eval only once
let init = false;
const doSomething = () => {
if (!init && (init = true)) {
console.log('Only once');
return;
}
console.log('Do something');
}
doSomething(); // Only once
doSomething(); // Do something
doSomething(); // Do something
doSomething(); // Do something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment