# Object doesn't support this action - For In Loop and IE

I’ve recently encountered a problem in Internet Explorer when I was using a for-in loop in one of my scripts. It was a simple loop too.

for (item in data) {
$row.data(item, data[item]); }  This piece of code will attach a data property for each JSON object it receives from an Ajax request. Simple, right? This works in every other browser I’ve tested it on, EXCEPT Internet Explorer. Turned out the word item is a reserved word or something an IE method, because when I swapped item with something else, like j or _item, the code immediately works. So something like this: for (_item in data) {$row.data(_item, data[_item]);
}


and this:

for (j in data) {
\$row.data(j, data[j]);
}


will work. But using item, without declaring what item is, will not.

Just in case someone else runs into this problem ;-)

Wassalam