|
|
|
|
|
by Meegul
3529 days ago
|
|
If you were to then reference 'x' from another block of code, say in another <script> element in the case of web development, 'x' would not be a defined variable, whereas with 'var', it would be. This is mostly just a case of 'let' restricting a variable to the block it is in, and the child blocks. In your example, `let x = 'outer';` is sort of acting like a global variable, but the importance is that if another script were to be running, it could not access that instance of 'x'. |
|
Somebody writing stuff, into the global namespace, directly in <script> tags, has bigger problems :-)