JavaScript Array isArray() method is used to determine whether a given value is an array. It returns a boolean value: true
if the value is an array, and false
otherwise. This method is particularly useful when working with dynamic data structures or verifying input types in your code.

Pre-requisites to Learn
Syntax
Array.isArray(value);
Parameters
Parameter | Description |
---|---|
value | The value to be checked if it is an array or not. |
Return Value
The Array.isArray() method returns true
if the provided value is an array, otherwise returns false
.
Examples of JavaScript Array isArray() Method
Example 1: Checking Simple Arrays
console.log(Array.isArray([1, 2, 3])); // Output: true console.log(Array.isArray('Hello')); // Output: false console.log(Array.isArray(123)); // Output: false
Here, the method accurately identifies the array [1, 2, 3]
and rejects non-array types like strings and numbers.
Example 2: Differentiating Between Arrays and Objects
let obj = { name: 'John', age: 30 }; let arr = [10, 20, 30]; console.log(Array.isArray(obj)); // Output: false console.log(Array.isArray(arr)); // Output: true
This example demonstrates that Array.isArray()
correctly distinguishes between objects and arrays.
Example 3: Checking Nested Arrays
let nestedArray = [[1, 2], [3, 4]]; let notArray = { 0: 'a', 1: 'b', length: 2 }; console.log(Array.isArray(nestedArray)); // Output: true console.log(Array.isArray(notArray)); // Output: false
Even for nested arrays, the method returns true
, while it rejects array-like objects.
Supported Browsers
Browser | Support |
---|---|
Chrome | 5+ |
Firefox | 4+ |
Safari | 5+ |
Edge | 12+ |
Opera | 10.5+ |
Internet Explorer | 9+ |