如何识别数组 1

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h1>JavaScript 数组</h1>
  6.  
  7. <p>当在数组上使用时,instanceof 运算符返回true:</p>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. var fruits = ["Banana", "Orange", "Apple", "Mango"];
  13. document.getElementById("demo").innerHTML = fruits instanceof Array;
  14. </script>
  15.  
  16. </body>
  17. </html>