JavaScript Array isArray() method

Definition and usage

isArray() Method to determine if an object is an array.

If the object is an array, this function returns true, otherwise it returns false.

Example

Check if the 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

Syntax

Array.isArray(obj)

Parameter value

Parameter Description
obj Required. The object to be tested.

Technical details

Return value: Boolean value. If the object is an array, it returns true, otherwise it returns false.
JavaScript version: ECMAScript 5

Browser support

All web browsers fully support isArray() Metod:

Chrome IE Edge Firefox Safari Opera
Chrome 5 IE 9 Edge 12 Firefox 4 Safari 5 Opera 10.5
2010 年 2 月 2010 年 9 月 2015 年 7 月 2010 年 7 月 2010 年 6 月 2010 år 3 månad

Relaterade sidor

Tutorial:JavaScript-array

Tutorial:JavaScript-array Const

Tutorial:JavaScript-arraymetoder

Tutorial:JavaScript-sortera array

Tutorial:JavaScript-arrayiteration