Answers for "check for not empty object javascript"

84

javascript check if object is empty

function isObjectEmpty(obj) {
    return Object.keys(obj).length === 0;
}
Posted by: Guest on July-24-2019
0

how find empty object in js

const emptyObject = {}

Object.entries(objectToCheck)
If it returns an empty array, it means the object does not have any enumerable property,
which in turn means it is empty.

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

Lodash, a popular library, makes it simpler by providing the isEmpty() function:
_.isEmpty(objectToCheck)
Posted by: Guest on January-14-2022

Code answers related to "check for not empty object javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language