Quantcast
Channel: How to efficiently count the number of keys/properties of an object in JavaScript - Stack Overflow
Viewing all articles
Browse latest Browse all 24

How to efficiently count the number of keys/properties of an object in JavaScript?

$
0
0

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 did provide a magic __count__ property, but this was removed somewhere around version 4.)


Viewing all articles
Browse latest Browse all 24

Latest Images

Trending Articles





Latest Images