You have to count them yourself:
function count(obj) {
var count=0;
for(var prop in obj) {
if (obj.hasOwnProperty(prop)) {
++count;
}
}
return count;
}
Although now that I saw the first comment on the question, there is a much nicer answer on that page. One-liner, probably just as fast if not faster:
function count(obj) { return Object.keys(obj).length; }
Be aware though, support for Object.keys()
doesn't seem cross-browser just yet.