Created
July 5, 2019 11:04
-
-
Save aliblackwell/04babbec9064f04972f6e71da265ab00 to your computer and use it in GitHub Desktop.
Block scope vs. functional scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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