JavaScript Array isArray() Method


The JavaScript Array isArray() method checks if the given argument is an Array or not.

The isArray() method is used to test whether the value passed is an array. If it finds the passed value is an array, it returns True. Otherwise, it returns False.

Syntax

Array.isArray(obj)

Parameters: This method accept a single parameter as mentioned above and described below:

  • obj: This parameter holds the object that will be tested.

Return value: This function returns the Boolean value true if the argument passed is array otherwise it returns false.

Example

function myFunction() {
  var fruits = ["Banana", "Orange", "Apple", "Mango"];
  var x = document.getElementById("demo");
  x.innerHTML = Array.isArray(fruits);
}

Example -