Created
October 3, 2012 06:27
-
-
Save qmmr/3825400 to your computer and use it in GitHub Desktop.
JavaScript: isArray()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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