Javascript examples for Array:isArray
The isArray() method returns true if the object is an array, and false if not.
Parameter | Description |
---|---|
obj | Required. The object to be tested |
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:
<!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>