Created
April 22, 2015 13:32
-
-
Save pcbulai/a55f7204e24324db702d to your computer and use it in GitHub Desktop.
Get JS object size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function objectSize (obj) { | |
var key, | |
size = 0; | |
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