Looks easy to implement using Vanilla JS instead of the library like Lodash’s function(isEmpty()).
Is it enough to check using Object.keys?
So just using the
Object.keys, it does return
true when the object is empty. But what happens when we create a new object instance using these other constructors.
That's not acceptable, because they are not an object, so the output should be false. We can fix this by adding a constructor check. Below is the example which explains the correct way to check an empty object.