iteration order for Object
Charles Kendrick
charles at isomorphic.com
Fri Mar 11 12:49:57 PST 2011
Yes Allen, hence the urgency. If IE9 final ships that way, the "goose is cooked":
1. we will have a new de facto standard iteration order for Object that does not match any
known use case - it is purely an implementation detail leaking through
2. the majority of real-world applications will be slowed down because developers will need to
re-implement the very commonly needed LinkedHashMap behavior in JavaScript
3. developers will waste a bunch of time doing this when the language could have provided it
4. developers will waste a bunch of time upgrading old sites and applications
5. JavaScript code will forever be more verbose than it needs to be wherever ordered maps are
needed
6. JSON messages will forever be more verbose than they need to be, and result in larger
JavaScript allocation and GC loads when eval()d/parsed
Against all this, we have various misunderstandings (thinking the iteration order of Array is
being affected, etc), but finally only:
1. for certain unusual use cases, implementers of code that use lots of integer indexes will
need to use Arrays for best performance - a perfectly reasonable optimization technique to
require, in my opinion
2. there may, in the immediate term only, for some unspecified use cases which may well be very
synthetic, be an advantage for JQuery, which may well vanish as JQuery evolves
On 3/11/2011 11:37 AM, Allen Wirfs-Brock wrote:
> On Mar 10, 2011, at 5:44 PM, Charles Kendrick wrote:
>
>> This behavior was perfectly consistent across all browsers until Chrome 6. I think it's more appropriate to say that Chrome is not interoperable with thousands of sites than to define interoperable behavior based on a minority browser's very very recent break from a de-facto standard that stood for 15 years.
>
> Note that it isn't just Chrome. IE9 also has similar behavior (at least in its late platform previews, I don't have the RC installed yet)
>
> On IE9 preview 1.9.8023.6000 standards mode:
>
> var a={x:'x', 3:3, 2:2,1:1}; a.a='a';
> print(Object.keys(a)); //--> 1,2,3,x,a
> print(JSON.stringify(a); //--> {"1":1,"2":2,"3":3,"x":"x","a":"a"}
> var k=''; for (var e in a) k+=e+" ";
> print(k); //--> 1 2 3 x a
>
>
More information about the es-discuss
mailing list