
Originally Posted by
paul_wilkins
The problem here is that you're trying to apply what you know from PHP on to JavaScript. Things don't work well that way.
Write in the language that you're writing in, is the maxim.
In this case, Array.isArray exists in JavaScript 1.8.5 and onwards.
You would do well though to investigate the compatibility code from the
Array.isArray documentation page, so that you can use the same technique in browsers that don't yet support JavaScript 1.8.5
Ok, so perhaps I'm still doing that PHP as JS thing.
Here is the issue now
Code:
if(!Array.isArray) {
Array.isArray = function (arg) {
return Object.prototype.toString.call(arg) == '[object Array]';
};
}
if(Array.isArray(nothing))
{
alert('Yes - an array');
} else {
alert('Not - an array');
}
Errors:
Error: nothing is not defined
Line: 60
Line: 60
Code:
if(Array.isArray(nothing))
Bookmarks