isArray
Functions to check the type of value if it's array or array-like.
isArray function
ts
function isArray(value: unknown): boolean
Checks if the passed value is an Array
. It does not check the value's prototype chain, nor does it rely on the Array
constructor it is attached to. It returns true
for any value that was created using the array literal syntax ([...]
) or the Array
constructor.
Parameters
value: unknown
The value to be checked.
Return boolean
true
if value is an Array
; otherwise, false
. false
is always returned if value is a TypedArray
instance.
isArrayLike function
ts
function isArrayLike(value: unknown): boolean
Checks if the passed value is array-like. A value is considered array-like if it's not a function and has a value.length
that's an integer greater than or equal to 0
and less than or equal to Number.MAX_SAFE_INTEGER
.
Parameters
value: unknown
The value to check.
Return boolean
true
if value has a valid length, otherwise false
.