Closed
Bug 791348
Opened 12 years ago
Closed 10 years ago
replace for-each statement to for-of statement
Categories
(Firefox :: General, defect)
Firefox
General
Tracking
()
RESOLVED
DUPLICATE
of bug 925989
People
(Reporter: teramako, Unassigned)
References
Details
ECMA-357(E4X) is deprecated.
We should use for-of statement instead of for-each statement
Updated•12 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 1•12 years ago
|
||
Bug 737792 did this on the browser side.
Will need to look at this a bit carefully: for-each works on both plain objects and arrays (although one should avoid using it with arrays), whereas for-of only works on arrays.
Quick test because I always confuse these forms... :/
for each (let a in { a:1, b:2 }) --> 1,2
for (let a of { a:1, b:2 }) --> Exception: not iterable
for (let a in { a:1, b:2 }) --> a,b
for each (let a in ["a", "b"]) --> a,b
for (let a of ["a", "b"]) --> a,b
for (let a in ["a", "b"]) --> 0,1
How about
for (let [, v] of Iterator({ a: 1, b: 2})) --> 1, 2
Comment 3•12 years ago
|
||
(In reply to teramako from comment #2)
> How about
>
> for (let [, v] of Iterator({ a: 1, b: 2})) --> 1, 2
Is for-each support going to be dropped? If not, I'd rather keep using it in such cases. Otherwise I'd use for-in with an extra assignment rather than what you propose.
(In reply to Dão Gottwald [:dao] from comment #3)
> (In reply to teramako from comment #2)
> > How about
> >
> > for (let [, v] of Iterator({ a: 1, b: 2})) --> 1, 2
>
> Is for-each support going to be dropped? If not, I'd rather keep using it in
> such cases. Otherwise I'd use for-in with an extra assignment rather than
> what you propose.
Not now, but for-each is defined by ECMA-357 and the specification is deprecated. Then for-each will be non-standard (not de-facto standard at least). Using standardized code as far as possible is better.
Comment 5•10 years ago
|
||
Is this a duplicate of bug 925989 ?
Updated•10 years ago
|
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•