test for an empty object in JavaScript

JavaScript
6
var obj = {};
if (Object.keys(obj).length === 0) {
console.log("Empty Object");
} else {
console.log("Not Empty Object");
}
🤖 Code Explanation
The code checks if an object is empty by checking the number of keys in the object. If the number of keys is 0, the object is empty.

More problems solved in JavaScript




















