我有对象&它的关键空值;
喜欢var obj = {newData : {}};
我想把if条件返回true或false。如何检查obj.newData是否有空对象?
答案 0 :(得分:0)
const obj = {newData : {}};
const obj2 = {newData : {x: 'x'}};
const isEmpty = testObj => Object.keys(testObj).length === 0;
console.log(isEmpty(obj.newData));
console.log(isEmpty(obj2.newData));