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.
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:
will work. But using item, without declaring what item is, will not.
Just in case someone else runs into this problem 😉
WassalamTags: for in loop, IE, internet explorer, Object doesn't support this action