![]() |
VOOZH | about |
These are the following ways to check whether the given set is empty or not:
The size property is used to get the size of the set. if it returns 0 then the set will be empty else it has some elements.
Empty set Not empty set
The Lodash is JavaScript library, that provide the _.isEmpty() Method, that checks whether the given set is empty or not and returns the boolean value.
Note: The function can take any value as a parameter to check, it is not limited to set only.
Output:
Empty setThe Array.from() method returns an array from any object with a length property. so it helps us to access the length property so that we can check its emptiness. This method does not alt the original object.
Not empty set