In this quick tip, you’ll learn how to check if an Object is empty in JavaScript.

Now, if an Object is empty it won’t be having any keys. So, the simplest method to check if an object is empty is to check if it has any keys or not.

You’ll be making use of Object.keys method in JavaScript to check if the object has any keys or not.

let obj = {};
if(Object.keys(obj).length > 0){
  console.log('Object is not empty');
} else {
  console.log('Object is empty');
}