how to check if object is empty javascript
snippet in javascript

javascript check if object is empty

user3959

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

how to check if object is empty javascript

user2842

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

javascript test for empty object

user1974

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

is check objet empty

user6074

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

es6 check if the object is empty

user7775

Object.entries(objectToCheck).length === 0