Chrome re-ordering object keys if numerics, is that normal/expected

后端 未结 7 1491

I noticed that certain code that evaluates some shoe sizes for an e-commerce site and outputs them on screen is messing up the order in Chrome.

JSON given can be:

7条回答
  •  情深已故
    2020-12-03 07:19

    When iterating over the properties of an object, the order is specified in the ECMAScript specification as being undefined and any order you may have observed in some environment should not be relied upon. If you need order, use an Array.

提交回复
热议问题