连接三个数组 - concat()

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h1>JavaScript 数组方法</h1>
  6.  
  7. <h2>concat()</h2>
  8.  
  9. <p>concat() 方法用于合并(连接)数组:</p>
  10.  
  11. <p id="demo"></p>
  12.  
  13. <script>
  14. var arr1 = ["Emma", "Isabella"];
  15. var arr2 = ["Jacob", "Michael", "Ethan"];
  16. var arr3 = ["Joshua", "Daniel"];
  17.  
  18. var myChildren = arr1.concat(arr2, arr3);
  19.  
  20. document.getElementById("demo").innerHTML = myChildren;
  21. </script>
  22.  
  23. </body>
  24. </html>