Last active
February 4, 2022 18:17
-
-
Save alexshelkov/b7911079d13707e96a8dce58da265ee7 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
{ // start of the block scope | |
// TODO: try uncomment | |
// console.log(a); | |
// hoisting works differently for blocks scope, and it will throw an error: | |
// 'ReferenceError: Cannot access a before initialization' | |
let a = 1; // 'a' defined and we can start to use it | |
// | |
console.log(a); | |
} // end of the block scope, here 'a' becomes not defined | |
// TODO: try uncomment | |
// TODO: try change let to var in code above | |
// console.log(a); | |
// 'a' is not defined here so we will see an error: | |
// 'ReferenceError: a is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment