问题
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