for (var i = 0; i < dt.length; i++) { if (Object.keys(dt[i]).length <= 1) { dt.splice(i, 1); i--;//splice删除后,数组长度会改变 } }
js获取对象的属性个数
var obj = {
key1:1,
key2:2,
key3:3
};
Object.getOwnPropertyNames(obj).length //3
Object.keys(obj).length //3