JavaScript .isArray()
Anonymous contributor
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 theArrayconstructor function and is not a prototype method. That is why.isArray()is called usingArray.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: trueconsole.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:
All contributors
- Anonymous contributor
- rclarkeweb
- Anonymous contributor
Christine_Yang
christian.dinh- robgmerrill
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
- Beginner Friendly.15 hours