.isArray()

The .isArray() method returns true for arrays, otherwise false.

Note: The .isArray() method is called on the Array constructor function and is not a prototype method. That is why .isArray() is called using Array.isArray().

Syntax

Array.isArray(value);

Required parameter value is the value to be checked.

Examples

Check if the following values are arrays:

console.log(Array.isArray([]));
// Output: true
console.log(Array.isArray({}));
// Output: false
console.log(Array.isArray(new Array(5)));
// Output: true
console.log(Array.isArray(true));
// Output: false

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn JavaScript on Codecademy