Skip to content

Instantly share code, notes, and snippets.

@qmmr
Created October 3, 2012 06:27
Show Gist options
  • Save qmmr/3825400 to your computer and use it in GitHub Desktop.
Save qmmr/3825400 to your computer and use it in GitHub Desktop.
JavaScript: isArray()
var isArray = function (obj) {
return obj && typeof obj === 'object' && obj.constructor === Array;
};
// doesn't detect if obj is array from other window or iFrame
var isArrayReally = function (obj) {
return Object.prototype.toString.apply(obj) === '[object Array]';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment