JavaScript Array isArray() Method
Example
Check whether an object is an array:
function myFunction() {
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var x = document.getElementById("demo");
x.innerHTML = Array.isArray(fruits);
}
Try it Yourself »
Definition and Usage
The isArray() method determines whether an object is an array.
This function returns true if the object is an array, and false if not.
Browser Support
Method | |||||
---|---|---|---|---|---|
isArray() | 5 | 9.0 | 4 | 5 | 10.5 |
Syntax
Array.isArray(obj)
Parameter Values
Parameter | Description |
---|---|
obj | Required. The object to be tested |
Technical Details
Return Value: | A Boolean. Returns true if the object is an array, otherwise it returns false |
---|---|
JavaScript Version: | ECMAScript 5 |
❮ JavaScript Array Reference