Skip to content

Instantly share code, notes, and snippets.

@philipjkim
Created August 1, 2012 08:17
Show Gist options
  • Save philipjkim/3224895 to your computer and use it in GitHub Desktop.
Save philipjkim/3224895 to your computer and use it in GitHub Desktop.
Check if an object is an array
var isArray = function(o){
return Object.prototype.toString.call(o) === '[object Array]';
};
console.log(isArray(['Soo', 'Philip', 'Kim'])); // true
console.log(isArray({first: 'Soo', middle: 'Philip', last: 'Kim'})); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment