How does js confirm that an object is empty?

how does js confirm that an object (Object) is empty?

Mar.31,2021

const isEmptyObject = obj => Object.getOwnPropertyNames(obj).length === 0

Object.keys (obj). Length = = 0


value instanceof Object && Object.keys(value).length == 0

since ES5/6+ 's method is mentioned upstairs to judge whether an object is empty or not, let's add a more general and compatible method.


,:

JSON.stringify(obj)=="{}"
Menu