I was trying out different objects and I noticed a little strange behavior in Javascript JSON objects. Would be great if someone can elaborate.
Example:
var bat={ 3:"FA", 7:"WER", 1:"JWRT",d:"EWR",a:"bA",8:"ADB"};
For this Json object, when it has integers as keys (works even if you enclose the integers in double quotes), and when you try to get the keys using Object.keys() or by simply printing bat the following order is seen.
{1: "JWRT", 3: "FA", 7: "WER", 8: "ADB", d: "EWR", a: "bA"}
The ordering does not happen automatically for Json Objects when the keys are strings (even if it is a Json Object containing string keys exclusively, or has integer and string keys interspersed).
In the case where there are string and integer keys in the same Json Object the integers get to the beginning of the array of keys.
Is there some reason for this behavior? Thanks in advance...