Created
May 20, 2019 23:19
-
-
Save jennz0r/c6f9f1242450344b7152072ba0214bde to your computer and use it in GitHub Desktop.
This file contains 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 simpleExample(value) { | |
if (value) { | |
var varValue = value; | |
let letValue = value; | |
console.log(varValue, letValue); // value value | |
} | |
// varValue is available even though it was defined | |
// in if-block because it was "hoisted" to function scope | |
console.log(varValue); // value | |
// letValue is a ReferenceError because | |
// it was defined within the if-block | |
console.log(letValue); // Uncaught ReferenceError: letValue is not defined | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment