Closed sevtapim closed 8 months ago
function isEmpty(obj) { return Object.keys(obj).length === 0; } //sample usage const john = { name: "John" }; isEmpty(john); // should return false isEmpty({}); // should return true
Thank you! check if object is empty in JavaScript
function isEmpty(obj) { return Object.keys(obj).length === 0; } //sample usage const john = { name: "John" }; isEmpty(john); // should return false isEmpty({}); // should return true