To check if an object is empty in JavaScript, do this:
Object.keys(object).length === 0
.Here's how you do it:
const emptyObject = {};
const nonEmptyObject = { Hello: 'World!' };
// true
console.log(Object.keys(emptyObject).length === 0);
// false
console.log(Object.keys(nonEmptyObject).length === 0);