.isArray()

Published Jun 21, 2021Updated Jul 13, 2023
Contribute to Docs

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.

Example

An empty array is passed into the .isArray() method:

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

Codebyte Example

In the examples below, the .isArray() method is used to check if values of various types are considered arrays:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn JavaScript on Codecademy