填充物体的物体长度? [英] Length of an object filled with objects?
本文介绍了填充物体的物体长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个装满物体的物体,我想知道它里面有多少物品。我怎么能用JS做到这一点?还在页面中运行jQuery。
I've got an object filled with objects and I want to know how many items are in it. How can I do this with JS? Also running jQuery in the page.
推荐答案
试试这个:
function countProperties(obj) {
var count = 0;
for (var prop in obj) {
if (obj.hasOwnProperty(prop))
++count;
}
return count;
}
这篇关于填充物体的物体长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文