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
  • 26,040
  • 6
  • 32
  • 55
Bhaurao Birajdar
  • 1,309
  • 10
  • 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
  • 313,535
  • 40
  • 245
  • 254