Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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)
Source by www.samanthaming.com #
 
PREVIOUS NEXT
Tagged: #find #empty #object #js
ADD COMMENT
Topic
Name
4+7 =