Skip to content

Instantly share code, notes, and snippets.

@mattbontrager
Last active October 6, 2017 20:24
Show Gist options
  • Save mattbontrager/5937409 to your computer and use it in GitHub Desktop.
Save mattbontrager/5937409 to your computer and use it in GitHub Desktop.
Check the length of a JavaScript Object as though it were an Array.
function checkObjectLength(obj) {
var key = 0;
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
key++;
}
}
return key;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment