isEmpty
Determine if a value is empty
493 bytes
Usage
Pass in a value and get a boolean telling you if the value is empty.
Empty values include:
null
undefined
0
- empty string
- empty array
- invalid
Date
time - object with
length
property of0
- object with
size
property of0
- object with no enumerable keys
Type Guards
In some cases, isEmpty
acts as a type guard, which helps TypeScript infer more specific types based on the check.
Due to TypeScript limitations, object types cannot be narrowed, except for arrays and functions.