Skip to content Skip to sidebar Skip to footer

Block Scoping Of Let And For…of

The let statement in ES2015 allows us to declare block scope variables, so that for example the following code does what we want: let fs = []; for (let i = 0; i < 3; i++) {

Solution 1:

As others pointed out in the comments, this broken behavior seems to be specific to Firefox, and the code is working properly in other environments (e.g. V8/Node).

As such, I have created a bug report for it. I’ll update this answer as I learn something new from the Firefox team.


This bug has been fixed around August last year and has since landed in the central codebase. The fix is now included in the Firefox 51 release that had its final release on January 24th, 2017.

I’m using the Firefox Nightly preview versions and it has been working there properly for a while.


Post a Comment for "Block Scoping Of Let And For…of"