Created
June 8, 2013 15:28
-
-
Save iliadraznin/5735510 to your computer and use it in GitHub Desktop.
Simple function to detect type Array.
JavaScript return type "object" whether you give it an actual object like { red:44, green:57, blue:220 }, or an array like [44, 57, 220]. So I wrote this small function to separate the two.
This file contains 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
function istype(obj) { | |
return (typeof obj !== 'object' || typeof obj[0] === 'undefined') | |
? typeof obj | |
: 'array'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment