我可以依靠以下代码在 a
之前提醒 b
吗?
var x = {}
x['b'] = 1
x['a'] = 0
for(var i in x) {
alert(i)
}
最佳答案
Are there any major browsers that do not preserve insertion order in a JavaScript Object?
至少有一个主流浏览器直到最近才这样做(我认为 V8 引擎没有保留顺序)。
Can I depend on the following code alerting b before a?
没有。规范说没有订单。
关于javascript - 是否有任何主流浏览器不保留 JavaScript 对象中的插入顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6139759/