In JavaScript, there are specific rules that dictate the order of object properties. One interesting example caught my attention.
When a timestamp in milliseconds is used as an object property key, the ordering does not function as expected.
However, if a timestamp in seconds is used as an object property key, the ordering works properly.
var objS = {
1600333200: 'a',
1600419600: 'b',
1600338600: 'c'
};
console.log('seconds', JSON.stringify(objS));
var objMs = {
1600333200000: 'a',
1600419600000: 'b',
1600338600000: 'c'
};
console.log('milliseconds', JSON.stringify(objMs));
Is there an explanation for this behavior?