Skip to content

Instantly share code, notes, and snippets.

@AhnMo
Last active September 26, 2018 16:32
Show Gist options
  • Save AhnMo/139a17ea83d3039096261899c701d1c8 to your computer and use it in GitHub Desktop.
Save AhnMo/139a17ea83d3039096261899c701d1c8 to your computer and use it in GitHub Desktop.
// inner closures
function create(i) {
return function () {
console.log(i);
};
}
for (var i = 0; i < 1; i++) {
setTimeout(create(i), 100);
}
// Please refer: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/let
for (let i = 0; i < 1; i++) {
setTimeout(() => console.log(i), 100)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment