JavaScript (ES2026) reference · Array Methods
JavaScript Array.isArray() Method
Return true if a value is an array. More reliable than typeof, which reports 'object' for arrays.
JavaScript (ES2026) Since ES5
Syntax
Array.isArray(value)
Parameters
| Parameter | Description |
|---|---|
value |
Any value. |
Return value
true or false.
Examples
console.log(Array.isArray([1, 2]), Array.isArray("text"), Array.isArray({ length: 0 }));
console.log(typeof [1, 2]);
Output
true false false object
function toList(x) {
return Array.isArray(x) ? x : [x];
}
console.log(toList(5), toList([5, 6]));
Output
[ 5 ] [ 5, 6 ]
Version history
| Version | Change |
|---|---|
| JavaScript ES5 | Added |
In other languages
isinstance()· Python
Related
Array.from()· Create a new array from an iterable or array-like object, with an optional function to map each element.Array.of()· Create a new array from its arguments. Unlike Array(3), Array.of(3) makes [3], not an empty array of length 3.- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial