Array isArray() Function - Javascript Array

Javascript examples for Array:isArray

Description

The isArray() method returns true if the object is an array, and false if not.

Parameter Values

Parameter Description
obj Required. The object to be tested

Return Value:

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

The following code shows how to Check whether an object is an array:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from w ww .  j  ava2 s  .  co  m
    var fruits = ["a","b","c","d","e"];
    var x = document.getElementById("demo");
    x.innerHTML = Array.isArray(fruits);
}
</script>

</body>
</html>

Related Tutorials