Javascript - Array isArray() Function

The isArray() method determines whether an object is an array.

Description

The isArray() method determines whether an object is an array.

This function returns true if the object is an array, and false otherwise.

Syntax

Array.isArray(obj)

Parameter Values

Parameter Require Description
obj Required. The object to be tested

Return

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

Example

Check whether an object is an array:

Demo

var myArray = ["XML", "Json", "Database", "Mango"];
console.log(Array.isArray(myArray));

console.log(Array.isArray("asdf"));

console.log(Array.isArray(null));

Result