I seem to be having an interesting problem only in chrome (not IE, FF). Given the following object:
var myObj = {
"59" : "Hello",
"52" : "and",
"50" : "how",
"31" : "are",
"65" : "you"
};
Going over this object via a for loop spits out the contents in the following order:
for(var j in myObj) { document.write(myObj[j] +', '); }
are, how, and, hello, you
All the other major browser give it in ‘proper’ order. Chrome is treating the keys as integers instead of strings. The problem is I have a json data source I can’t change, and I need to access the items in the order they’re in the object.
Can anyone suggest a way to do this in Google Chrome?
When iterating over an object via
for...in, the order of properties is not guaranteed. There is nothing you can do:And from the
deletepage: