isArrayLike
Checks if a value is array-like: has a non-negative integer length property.
Returns true for arrays, strings, arguments objects, NodeList, typed
arrays, and any object with a valid length. Functions are excluded even though
they have a length (arity), as they are not considered array-like in practice.
Available since v2.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
Section titled “Returns”value is ArrayLike<unknown> — true if value is array-like
Examples
Section titled “Examples”Detect array-like values
Section titled “Detect array-like values”Arrays, strings, and objects with a non-negative integer length are array-like.
Convert an array-like value to an array
Section titled “Convert an array-like value to an array”Use as a guard before Array.from().
