I believe the ECMA spec does not require implementors to maintain key
order, though historically browser implementors have chosen to do so.

It's best not to count on them being in order, IMO.

Hope this helps!

-- Jim R. Wilson (jimbojw / hexlib)

On Friday, November 26, 2010, chrislewis <burningodzi...@gmail.com> wrote:
> Hello,
>
> Can someone comment on the ordering of object keys? It seems that V8
> and SpiderMonkey both preserve the defined order, but Rhino does not.
> Consider this example:
>
> for(var k in { b: 'b', c: 'c', a: 'a' }) console.info(k);
>
> In V8 and SpiderMonkey, the output is:
> b
> c
> a
>
> The equivalent snippet in Rhino:
>
> for(var k in { b: 'b', c: 'c', a: 'a' }) println(k);
>
> Outputs:
> a
> b
> c
>
> I'm prototyping an app, and this has posed a slight pain. Is the key-
> order actually specified, and if so, can this be corrected in Rhino?
> If not, I guess I'll have to change my approach.
>
> Thanks,
> chris
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-engine-rhino@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
dev-tech-js-engine-rhino@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to