/* The Array.isArray() method indicates whether
the passed value is an array. */
let example1 = [1, 2, 3];
console.log(Array.isArray(example1)); // → true
let example2 = {a: 1, b: 2,c: 3};
console.log(Array.isArray(example2)); // → false
<!DOCTYPE html>
<html>
<body>
<p>Click the button to check if "fruits" is an array.</p>
<button onclick="checkArrayValueOrNot()" id="btnClick">Click </button>
<p id="demo"></p>
<script>
function checkArrayValueOrNot() {
var states =["Maharashtra","Tamil Nadu","Uttar Pradesh","West Bengal","Delhi"];
var x = document.getElementById("demo");
x.innerHTML = Array.isArray(states);
}
</script>
</body>