Borrowing from Prototype.js, ECMAScript 5 defines two nifty new methods Object.keys(obj) and the rather clunkily named Object.getOwnPropertyNames(obj). They already work in the current versions of Chrome and Safari and will be supported in Firefox 4 and IE9. cojahmetov/objectkeys.js. Created Apr 6, 2015. Embed. Object.keys(a).length var count 0 var iThere is a collection size method, as well as a toArray method, which may get you what you need. Ok. I do not like to use many .js files (may be kind of a messy), so I think to merge jquery. js and underscore.js in on file jquery.js for example, and use You can simply use Object.keys(obj).length on any object to get its length. Object.keys returns an array containing all of the object keys (properties) which can come in handy for finding the length of that object using the length of the corresponding array. Get web development help.