Possible Duplicate:
Chrome and probably Opera sort object properties automatically
I have a very simple code:
var obj = {3:'a',2:'b',1:'c'};
console.log(obj);
In Firefox 4.0.1 it returns:
Object { 3="a", 2="b", 1="c"}
In Chrome 11.0.696.71 it returns:
Object { 1="c", 2="b", 3="a"}
How can I coerce Chrome doesn’t sort this object?
It’s a known “bug”/feature of chrome. Even author of jQuery indignant of this, but chrome guys stay inflexible, saying that this is a “feature”:
http://code.google.com/p/chromium/issues/detail?id=883 [1]
As a workaround use arrays or some kind of MixedCollection (as in extjs) or something similar.
[1]: John Resig (jeresig) is an author of jquery