Skip to content

Instantly share code, notes, and snippets.

@jennz0r
Created May 20, 2019 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jennz0r/c6f9f1242450344b7152072ba0214bde to your computer and use it in GitHub Desktop.
Save jennz0r/c6f9f1242450344b7152072ba0214bde to your computer and use it in GitHub Desktop.
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