Reputation: 419
I am having an issue that only occurs in IE9, it doesn't happen in Chrome or Firefox.
Basically I have an object called Results, which contains multiple objects. I'm just trying to do a simple loop through the obects in the Results object using the name as a key for each object, but for some reason using the name of the object as a key or trying a number index does not return anything from Results in IE9. Using a number index does not return a object in any browser.
The results object looks like this at runtime, its taken from FireBug so sorry about the format
results
[]
NUMBER0
Object { type="textbox", name="NUMBER0", answer="3125"}
NUMBER1
Object { type="textbox", name="NUMBER1", answer="135"}
Number0 and Number1 are the names of the object inside results.
This is the simple for loop I'm using, item below will have a value of either "Number0" or "Number1":
for (item in results) {
var question = results[item];
// do something with question here
}
So as I said in FireFox and Chrome this returns the correct object and I can continue but in IE9 it doesn't work. I haven't tried any other versions of IE and I have made sure that IE9 is not in IE 7 or 8 mode.
Any ideas would be great.
Anthony
Upvotes: 0
Views: 99
Reputation: 39777
It looks like results
is an array []
, so if it's not empty, "number index" should work. Try iterating thru it like this:
for (var i=0; i < results.length; i++) {
var question = results[i]
}
Unless it's an empty array object that has other items assigned to it as properties. In that case... I suggest rethinking your design.
Upvotes: 1