So the lodash _.isEmpty method can be used to check if an object collection is empty or not. If the collection is just an object with one or more public key value pairs then it is not empty, the same is true with arrays when they have one ore more indexed values.
This is the intended use of the is empty method in lodash
The lodash is empty method is for finding out if a collection does not have any items and that is it. It is not for finding out if a value fits other meanings of what the word empty might mean to some. For example when passing boolean values to the is empty method a boolean value will always return true even if the value is false.
Before I can check the key length of an object first I might want to make sure that I am dealing with an object by making use of the typeof keyword and checking if the type is indeed object. I also need to make sure that I am not dealing with a null value because that will return as object for typeof also. I can then just pass the object to to Object.keys method and check the length of the resulting array of key names returning true of false depending on the length. I can then later in the method return true by default for anything and everything else that might be passed.
Seems to work more or less just as well compared to the lodash isEmoty method.
the ldoash is empty method is an example of a collection method in lodash, which in other words means that it will work with both objects and arrays in general. I can not say that the lodash is empty method is the best example of this in lodash, but understanding the differences between Arrays and other Objects is important in any case. The real difference is juts that when dealing with arrays it is just more or less an object just like any other only it is a collection of numbered rather than names key names for elements, a length property, and it is an instance of the Array constructor. Other than that an Array is just another Object just like any other, and as such certain methods such as this will work with Objects in general.