javascript check empty object
snippet in javascript

javascript check if object is empty

user7062

function isObjectEmpty(obj) {
    return Object.keys(obj).length === 0;
}

javascript check empty object

user7168

function isEmptyObject(obj) {
    return !Object.keys(obj).length;
}

javascript test for empty object

user5614

// because Object.entries(new Date()).length === 0;
// we have to do some additional check
Object.entries(obj).length === 0 && obj.constructor === Object