Closed
Bug 1321848
Opened 8 years ago
Closed 8 years ago
Using let keyword with (for..in) and (for..of)
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 449811
People
(Reporter: jbass86, Unassigned)
Details
Was writing an webapp in the latest version of firefox (50.0.2) and noticed while using let in a for loop declaration that it doesn't behave as I would expect. The following code for example: var something = {a: "a", b: "b", c: "c"}; for (let name in something){ window.setTimeout(()=>{ console.log(name); }, 1000); } will yield the following output : Chrome(54.0.2840.99): a b c Firefox(50.0.2): c c c The same behavior seems to be present with (for..of) as well. It does seem however that if you use "for (let i = 0; i < x; i++)" syntax then the variable will be scoped correctly. I tested this on Redhat Rhel7, Windows7 and Windows10.
Comment 1•8 years ago
|
||
This should be fixed in Firefox 51, which also happens to be the current Firefox beta release.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•