Skip to content

Instantly share code, notes, and snippets.

@ronalddddd
Created January 17, 2016 09:39
Show Gist options
  • Save ronalddddd/8d3c4e90b45d067d478f to your computer and use it in GitHub Desktop.
Save ronalddddd/8d3c4e90b45d067d478f to your computer and use it in GitHub Desktop.
ES6 function vs block scope example
for (var i=0; i<5; i++){
setTimeout(() => console.log('function-scoped i:', i), 100);
}
for (let i=0; i<5; i++){
setTimeout(() => console.log('block-scoped i:', i), 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment