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

后端 未结 7 1508

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:13

    I found an easy work around using underscore.js

    myArray = _.sortBy(myArray, function(num){ return Math.ceil(num); });
    

    Yay! myArray is back to the correct order in all browsers.

提交回复
热议问题