Possible Duplicate:
Does JavaScript Guarantee Object Property Order?
I notice that in Javascript (on Chrome, at least) objects remember the order of their members. For example, in
var foo = { x: 1, y: 2 }
var bar = { y: 2, x: 1 }
foo
and bar
are distinguishable by the order the keys appear when I iterate over them.
My questions are:
- Is this behavior specified by the standard, or should it be considered an implementation detail?
- If it is specified by the standard, is there a way to change the order?