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? (是否可以在不迭代对象的情况下执行此操作?)
ie 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.)
((Firefox确实提供了一个神奇的__count__
属性,但此属性已在版本4的某个位置删除。))
ask by mjs translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…