代码示例:(标识:eg_js_array_isarray)
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Array.isArray()</h1>

<p>单击按钮以检查“fruits”是否为数组。</p>

<button onclick="myFunction()">试一试</button>

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

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

</body>
</html>
运行结果: