Can I depend on the following warning code b to a ?
b
a
var x = {} x['b'] = 1 x['a'] = 0 for(var i in x) { alert(i) }
For the JavaScript V8 engine used in Google Chrome, a similar discussion was held:
http://code.google.com/p/v8/issues/detail?id=164
Better not to rely on undocumented features. And that you use numbers as keys, it certainly goes wrong.
For example, this breaks down in some browsers:
var x = {} x['b'] = 1 x['2'] = 20 x['a'] = 0 x['1'] = 10 for(var i in x) { alert(x[i]) }
BTW it alert(x[i]) .
alert(x[i])
Are there any major browsers that do not preserve the insertion order in the JavaScript object?
Until recently, at least one large browser (I think that the V8 engine did not keep order).
Can I depend on the following warning code b before?
Not. The spectrum says there is no order.