How to efficiently count the number of keys/properties of an object in JavaScript?
- by mjs
What's the fastest way to count the number of keys/properties of an object? It it possible to do this without iterating over the object? i.e. without doing
var count = 0;
for (k in myobj) if (myobj.hasOwnProperty(k)) count++;
Firefox provides a magic __count__ property, but this isn't available in other implementations.