isArray
Checks whether a value is an array.
This helper never throws and never mutates input. Use it when you need to confirm that a value is an array before running normalization or validation.
Signature
function isArray(value: unknown): value is unknown[]
Parameters
| Name | Data type | Description |
|---|---|---|
| value | unknown |
The unknown value to check. Must be validated explicitly; no assumptions or coercion are applied. |
Returns
A boolean:
true: If the value is an array.false: Otherwise.
Examples
isArray([]) // true
isArray([1, 2, 3]) // true
isArray(["a", "b"]) // true
isArray({}) // false
isArray(null) // false
isArray("hello") // false
isArray(123) // false
Notes
- This helper uses
Array.isArrayinternally. - Use
normalizeArrayif you need to ensure a value becomes an array. - Use
validateArrayif you need aResult<T>instead of a boolean.