Google Chrome: JavaScript associative arrays, evaluated out of sequence

前端 未结 7 2117
耶瑟儿~
耶瑟儿~ 2020-12-07 02:24

Ok, so on a web page, I\'ve got a JavaScript object which I\'m using as an associative array. This exists statically in a script block when the page loads:

v         


        
7条回答
  •  情歌与酒
    2020-12-07 02:46

    As the other answers say, the order in which an object's properties are iterated is not defined in the spec, even though the major browsers all iterate them in the defined order.

    Chrome will enumerate them in order too, if all of the object's properties contain primitive values. John Resig gives more detail on Chrome's behavior here (under "for loop order"): http://ejohn.org/blog/javascript-in-chrome/

提交回复
热议问题