Skip to content

Instantly share code, notes, and snippets.

@takumakei
Created October 19, 2011 14:57
Show Gist options
  • Save takumakei/1298538 to your computer and use it in GitHub Desktop.
Save takumakei/1298538 to your computer and use it in GitHub Desktop.
is_array
// is_array():bool
// "JavaScript: The Good Parts by Douglas Crockford. Copyright 2008 Yahoo! Inc., 978-0-596-51774-8."
function is_array(value) {
return value &&
typeof value === 'object' &&
typeof value.length === 'number' &&
typeof value.splice === 'function' &&
!(value.propertyIsEnumerable('length'));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment