News for hackers. Stuff that matters.
Re:Overview of JavaScript ES6 features by Meegul on Monday October 24, 2016 @02:48PM (#12781631)
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'.

Re:Overview of JavaScript ES6 features by Roboprog on Monday October 24, 2016 @08:39PM (#12784247)
Ehw. Yeah, I sort of assumed that you had a top level function / IIFE (in a .js file, FWIW) in which the var's were nested.

Somebody writing stuff, into the global namespace, directly in <script> tags, has bigger problems :-)

Re:Overview of JavaScript ES6 features by SHOwnsYou on Tuesday October 25, 2016 @10:09AM (#12788108)
Ahh, I get it, Thank you! In the same way var scopes to window if defined outside of a function, let scopes it to the current script block. That is very neat.

I'll read more into uses of let over var. Function level scoping a la var feels like less mental overhead, but as I read more I'm sure my opinion will change.