Created
January 13, 2020 14:57
-
-
Save cesarkohl/db27f0672e629a382f701d14f9dee723 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
| let value = 0; | |
| if (true) { | |
| // new scope, TDZ of 'value' begins | |
| // When trying to access the variable, we take ReferenceError, | |
| // because right now it's a variable | |
| // not initialized | |
| console.log (value); // ReferenceError | |
| let value; // TDZ ends and 'value' is set to 'undefined' | |
| console.log (value); // undefined | |
| value = 1; | |
| console.log (value); // 1 | |
| } | |
| console.log (value); // 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment