isNonEmpty
Checks if an array is non-empty (has at least one element).
null and undefined are treated as empty arrays and return false.
Available since v2.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | readonly T[] | null | undefined | The array to check |
Returns
Section titled “Returns”value is readonly [T, T] — true if the array has at least one element; false for empty, null, or undefined
Examples
Section titled “Examples”Check if an array has elements
Section titled “Check if an array has elements”Returns true for arrays with at least one element, regardless of the element values.
Safe first-element access with type narrowing
Section titled “Safe first-element access with type narrowing”In the true branch, the type narrows to [T, …T[]], making arr[0] always defined.
