Iteration in ES4

Waldemar Horwat waldemar at google.com
Mon Apr 28 18:04:24 PDT 2008


Brendan Eich wrote:
> 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.

I'm baffled trying to figure out what you're trying to say in the last paragraph.

    Waldemar



More information about the Es4-discuss mailing list