Skip to content

Instantly share code, notes, and snippets.

@joshuacerbito
Last active May 19, 2016 02:14
Show Gist options
  • Save joshuacerbito/1f95f0eaefa7a594d84ebbeebf285c3c to your computer and use it in GitHub Desktop.
Save joshuacerbito/1f95f0eaefa7a594d84ebbeebf285c3c to your computer and use it in GitHub Desktop.
Get the size of an object
Object.size = function ( obj ) {
var size = 0, key;
for (key in obj) {
if ( obj.hasOwnProperty(key) ) { size++; }
}
return size;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment