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

ParameterDescription
value Any value.

Return value

true or false.

Examples

Check for arraysTry it yourself
console.log(Array.isArray([1, 2]), Array.isArray("text"), Array.isArray({ length: 0 }));
console.log(typeof [1, 2]);

Output

true false false
object
Accept one value or manyTry it yourself
function toList(x) {
  return Array.isArray(x) ? x : [x];
}
console.log(toList(5), toList([5, 6]));

Output

[ 5 ] [ 5, 6 ]

Version history

VersionChange
JavaScript ES5Added

In other languages