Posts Tagged ‘javascript’

How to properly check if a variable is an array in JavaScript

Monday, October 4th, 2010

I just came across this post which details how to check if a variable is an array in JavaScript. The final word:

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

Scary stuff.