Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript isArray() Method

JavaScript isArray() Method

Array Object Reference JavaScript Array object

Example

Determine 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 »


Definition and Usage

The isArray() method is used to determine whether an object is an array.

Returns true if the object is an array, otherwise returns false.


Browser support

The numbers in the table indicate the first browser version that supports this method.

Method
isArray() 5 9.0 4 5 10.5

Syntax


Array.isArray(obj)

Parameters

Parameters Description
obj Required. The object to be tested.

Technical Details

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

Array Object Reference JavaScript Array object