Skip to content

Instantly share code, notes, and snippets.

@aliblackwell
Created July 5, 2019 11:04
Show Gist options
  • Save aliblackwell/04babbec9064f04972f6e71da265ab00 to your computer and use it in GitHub Desktop.
Save aliblackwell/04babbec9064f04972f6e71da265ab00 to your computer and use it in GitHub Desktop.
Block scope vs. functional scope
/*
var - functional scope == function declaration curly braces
let/const - block scope == curly braxes
*/
for (let i=0; i<something.length; i++) {
// i is only in here
}
// i is not valid here because of block scope
function myIterator() {
for (var j=0; i<something.length; j++) {
// j is in here
}
// j is also valid here because of functional scope
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment