Iteration in ES4

Brendan Eich brendan at
Fri Apr 25 14:12:34 PDT 2008

On Apr 25, 2008, at 2:08 PM, Brendan Eich wrote:

> for (prop in obj) {
>      ... obj[prop] ...
> }
> to look like
> for each (value in obj) {
>      ... value ...
> }
> where obj might be an Array. The symmetry between for-each-in and for-
> in that E4X half-supports (viz, prototype property enumeration with
> shadowing, and deleted-after-loop-starts coherence) is broken.

Just in case this is not well-known, SpiderMonkey starting in Firefox  
1.5 supported E4X and made the for-each-in loop work for all object  
types, not just XML/XMLList. But not on Array element (indexed  
property) values only, in index order -- again property creation  
order, and named as well as indexed enumerable properties, are  
visited. This shares code with for-in and preserves the equivalence  
shown in the rewrite example above.


More information about the Es4-discuss mailing list