0

I have object & its key empty value;

like var obj = {newData : {}};

I want to put if condition that return true or false. how can I check that obj.newData has empty object or not?

Eddie
  • 25,279
  • 6
  • 26
  • 53
Bhaurao Birajdar
  • 1,149
  • 9
  • 15

1 Answers1

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));
CertainPerformance
  • 260,466
  • 31
  • 181
  • 209