isEmpty
Checks if an array is empty (has no elements).
null and undefined are treated as empty arrays and return true.
Available since v2.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | readonly unknown[] | null | undefined | The array to check |
Returns
Section titled “Returns”value is readonly never[] | null | undefined — true if the array has no elements, or if value is null/undefined
Examples
Section titled “Examples”Check if an array is empty
Section titled “Check if an array is empty”Returns true only for arrays with no elements.
Guard before accessing first element
Section titled “Guard before accessing first element”Use isEmpty as an early-return guard for arrays, null, and undefined; the false branch is safely non-empty.
