Home >>JavaScript Array Reference >JavaScript Array isArray() Method
JavaScript isArray() Method is used to determines the value passed to this method is an array. In case, if it find the argument passed is an array, the function returns true else it returns false.
Syntax:Array.isArray(obj)
Parameter | Description |
---|---|
obj | It is Required. It is the object to be tested |
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
isArray() | 5 | 9.0 | 4 | 5 | 10.5 |
<html> <body> <button onclick="myArr()">Click me</button> <p id="isArr"></p> <script> function myArr() { var fruits = ["Orange", "Apple", "Bananan", "Mango"]; var x = document.getElementById("isArr"); x.innerHTML = Array.isArray(fruits); } </script> </body> </html>
<html> <body> <script> function isArray() { document.write(Array.isArray('toolbar')); } isArray(); </script> </body> </html>