function getObjectLength(obj) {
var i = 0;
for(var k in obj){
i++;
}
return i;
}
var obj = {
a: 1,
b: 2,
c: {
c1: 3,
c2: 4
}
};
console.log(getObjectLength(obj)); // 3
function getObjectLength(obj) {
var i = 0;
for(var k in obj){
i++;
}
return i;
}
var obj = {
a: 1,
b: 2,
c: {
c1: 3,
c2: 4
}
};
console.log(getObjectLength(obj)); // 3
转载于:https://www.cnblogs.com/pssp/p/5277003.html