Created
February 25, 2018 14:57
-
-
Save abel-masila/0a71d4f1fa717aa065fa71812dcfae3c to your computer and use it in GitHub Desktop.
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
function loop(arr) { | |
// i IS NOT known here | |
// j IS NOT known here | |
for( var i = 0; i < arr.length; i++ ) { | |
// i IS known here | |
} | |
// i IS known here | |
// j IS NOT known here | |
for( let j = 0; j < arr.length; j++ ) { | |
// j IS known here | |
} | |
// i IS known here | |
// j IS NOT known here | |
} | |
///Here, we can see that our variable j is only known in the first for loop, but not before and after. | |
//Yet, our variable i is known in the entire function from the moment it is defined onward. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment