📜  如何在 js 中找到空对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:35.007000             🧑  作者: Mango

代码示例1
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)