连接两个数组 - 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 myGirls = ["Emma", "Isabella"];
  15. var myBoys = ["Jacob", "Michael", "Ethan"];
  16. var myChildren = myGirls.concat(myBoys);
  17.  
  18. document.getElementById("demo").innerHTML = myChildren;
  19. </script>
  20.  
  21. </body>
  22. </html>