In JavaScript the typeof operator reports an array as 'object'. While this is technically correct (an array in JavaScript is really just a specialized object), it's a pain in the neck when you are type checking a variable.
There are a number of ways to identify an array in JavaScript. Checking for properties of an array isn't totally accurate because you can add any named member to an object to imitate an array. Checking for 'instanceof Array' works most of the time but could be tricky in some implementations of JavaScript.
Mark Miller of Google gives us a solution that is standard to the ECMAScript documentation:
Object.prototype.toString.apply(value) === '[object Array]';
What this essentially does is take the standard Object method "toString" and applies it to the passed argument (which is your array you are checking). This makes sure that it reports itself according to standard, which all real arrays should. We can implement it in an easy checking function that returns a boolean:
function isArray(a)
{
return Object.prototype.toString.apply(a) === '[object Array]';
}
Props to Douglas Crockford because I read about this on his blog. There is also some further discussion there on using this method and i recommend reading it.
As a bonus of sorts, this also works in ActionScript 2.0 and ActionScript 3.0.