In ES6, do for loops with a let/const initializer create a separate scope?

Andreas Rossberg rossberg at google.com
Mon Jun 16 02:07:52 PDT 2014


On 13 June 2014 18:23, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> We could consider special cases loop bodies that are BlockStatements and statically reject those that contain declaration that shadow the loop declarations.  However, I think it is probably best to leave that sort of check for linters to perform.

Yes. A block is a block, and block scoping has shadowing semantics. I
see no point in making exceptions to this rule in a few random places.
In fact, non-compositional scoping restrictions can be harmful, since
they can get in the way of e.g. refactoring or JS as a compilation
target.

/Andreas


More information about the es-discuss mailing list