Brendan Eich wrote: > More helpful would be comments on the utility of let > blocks (a.k.a. let statements) and let expressions.
While reading up on this, I noticed that you can declare the same name with both let and var in the same scope: var x = 'global'; let x = 42; Even if you do this in the global scope or function top level, both will exist, in the same scope, one shadowing the other (but details differ between texts and test results). In my opinion this is not a useful feature, quite the contrary. If the variables are far apart on the page, the disappearance of one of them will be mysterious and difficult to debug. It becomes trivial to solve if instead an error is thrown, reporting conflicting declarations. In the special case of global and function-top-level scope, intuitively let and var seem synonymous. But throwing an error seems fine too. { let x; { var x = 10; } } The let hides the var. This should throw an error too, as I see it. If a name can't be reached where it's declared, that's hard to debug. -- Ingvar von Schoultz _______________________________________________ Es-discuss mailing list Es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss