1

i'm curious why IE8 chokes on the line

if (isArray(obj))

This is what I get in the IE8 javascript console:

>>obj
{...}
>>typeof(obj)
"object"
>>Object.prototype.toString.call(obj)
"[object Array]"

and even

>>obj.length
7

However,

>>isArray(obj)
  Object expected

Why is that happening (ie8 doesn't support of isArray?) and what's the best way to fix it?

I'm trying to use new version of Angular for IE8. I know it is not officially supported however I will give a try the app to work better or worse.

Thank you.

Haradzieniec
  • 9,086
  • 31
  • 117
  • 212
  • 1
    I think that this thread is related to what you are after. http://stackoverflow.com/questions/1058427/how-to-detect-if-a-variable-is-an-array –  Apr 10 '15 at 15:48

1 Answers1

8

since IE 9 there is Array.isArray().

try this:

Array.isArray = function (obj) {
    return Object.prototype.toString.call(obj) === "[object Array]";
};

Array.isArray(obj);
dolek
  • 214
  • 1
  • 8