Check if objects are empty in Javascript
· ☕ 2 min read
Check if a given object is empty without considering any custom props defined by prototype.
Consider this sample object -
1 const earth = {}; Use Object.entries() or equivalent Object.entries gives us a short way to access entries in an array form. We could just check whether entries are empty to decide whether the parent object is empty.