Object.keys order in React Native

梦想的初衷 提交于 2019-12-24 11:19:14

问题


Is it safe to assume that calling Object.keys() on object always returns array in the same order? I mean it wasn't specified in JS until ES2015 but I'm not sure how it is exactly in React Native?


回答1:


Property keys are traversed in the following order:

First, the keys that are integer indices in ascending numeric order.

Then, all other string keys, in the order in which they were added to the object.

Lastly, all symbol keys, in the order in which they were added to the object.

Many engines treat integer indices specially (even though they are still strings, at least as far as the ES6 spec is concerned). Therefore, it makes sense to treat them as a separate category of keys.



来源:https://stackoverflow.com/questions/57929125/object-keys-order-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!