Iterating JavaScript object properties and arrays with for..in when ordering is important

前端 未结 3 555
醉梦人生
醉梦人生 2021-01-14 07:18

This has been an age old question and I am aware of the usual reasons for not using for..in or perhaps even objects when any sort of ordering is needed, but I r

3条回答
  •  佛祖请我去吃肉
    2021-01-14 07:28

    Tests on IE 5.5-6-7-8 showed the exact same behavior. The properties are ordered. The deleted property keeps its position.

    But as it is non-standard behavior it can break with IE9, or any browser's next version...

    And maybe I've missed something but what's the point? Saving some characters in comparison to a more robust code, that runs well with 3rd party ads, tracking systems, widgets etc.?

    Let alone supporting mobile browsers, and the desktop ones with tiny market share.

提交回复
热议问题