4 ms·
Why does it have to be that the order of members matters? shouldn't both {x,y,z} and {z,x,y} compile down to {x,y,z}?
by axilmar 8y ago
Why does it have to be that the order of members matters? shouldn't both {x,y,z} and {z,x,y} compile down to {x,y,z}?
- fpoling 8y agoIn JS for-in loop enumerates keys in the insert order. So {x,y,z} is different from {z,x,y}
- mort96 8y agoAFAIK, that's not true; the spec doesn't guarantee that it iterates in insertion order, it's just how it's commonly implemented in browsers.
- topaxi 8y agoNope, they should be iterated in their defined order: https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys I think they added this with ES2015.