In modern browsers you can do:
Array.isArray(obj)
For backward compatibility you can add the following:
// only implement if no native implementation is available
if (typeof Array.isArray === 'undefined') {
Array.isArray = function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
}
};
Purvi Barot
Software Engineer
In modern browsers you can do:
Array.isArray(obj)For backward compatibility you can add the following:
// only implement if no native implementation is available if (typeof Array.isArray === 'undefined') { Array.isArray = function(obj) { return Object.prototype.toString.call(obj) === '[object Array]'; } };