Skip to content

Instantly share code, notes, and snippets.

@ryanmorr
Last active August 4, 2016 23:54
Show Gist options
  • Save ryanmorr/ad5e406f62f67a30d30c9d7015c4d5d4 to your computer and use it in GitHub Desktop.
Save ryanmorr/ad5e406f62f67a30d30c9d7015c4d5d4 to your computer and use it in GitHub Desktop.
Check if an object has the characteristics of an array-like object
function isArrayLike(value) {
return value
&& typeof value === 'object'
&& typeof value.length === 'number'
&& value.length >= 0
&& value.length % 1 === 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment