Skip to content

Instantly share code, notes, and snippets.

@carlinmack
Last active December 27, 2018 22:11
Show Gist options
  • Save carlinmack/5a0353f610524a8704105a2e9cf1c3af to your computer and use it in GitHub Desktop.
Save carlinmack/5a0353f610524a8704105a2e9cf1c3af to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/xejuloh
function baz() {
let val;
return function bar() {
if (val === undefined) {
console.log('working');
val = ['values', 'values']
return val;
} else {
return val;
}
}
}
let foo = baz();
for (var i = 0; i < 10; i++) {
console.log(foo());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment