Created
July 10, 2010 04:46
-
-
Save tinyfly/470441 to your computer and use it in GitHub Desktop.
Array Detection
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
/* | |
Since using the typeof operator to test an array returns 'object' | |
we need another way to test it. | |
( via http://jqfundamentals.com/book/book.html#N20659 ) | |
*/ | |
var is_array = function (my_array) { | |
if (Object.prototype.toString.call(my_array) === '[object Array]') { | |
return true; | |
} | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is now built in to the language:
Array.isArray(my_array)