iteration order for Object

Charles Kendrick charles at isomorphic.com
Thu Mar 10 18:00:05 PST 2011


Yes, great performance enhancements are available for *Arrays* - but this is not relevant 
because as I explicitly stated, I am not suggesting anything be clarified or standardized with 
respect to for..in order for Arrays.

People use Objects as classes, instances, "associative arrays" / Maps, etc.  Numeric keys are a 
tiny minority and there would be no measurable performance gains for special treatment of such 
keys *on Object*.

However because frameworks have to deal with all possible keys, we end up with a much, much 
more expensive data structure that has to be used just because numeric keys are being treated 
specially.

This means that the real-world, application-level impact of not preserving order is *slower* 
applications.

On 3/10/2011 5:48 PM, Boris Zbarsky wrote:
> On 3/10/11 8:44 PM, Charles Kendrick wrote:
>> It requires
>> browser vendors to implement order preservation, such that we don't get
>> the minor
>> optimization that's possible from not preserving order at all.
>
> For what it's worth, not preserving order for numeric properties allows optimizations that are
> decidedly not "minor".
>
> You can compare the performance of "fast" and "slow" arrays in Spidermonkey to see the difference.
>
> -Boris


More information about the es-discuss mailing list