Skip to content

Instantly share code, notes, and snippets.

@tinyfly
Created July 10, 2010 04:46
Show Gist options
  • Save tinyfly/470441 to your computer and use it in GitHub Desktop.
Save tinyfly/470441 to your computer and use it in GitHub Desktop.
Array Detection
/*
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;
};
@tinyfly
Copy link
Author

tinyfly commented Feb 14, 2020

This is now built in to the language: Array.isArray(my_array)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment