Combining arrays in JS

后端 未结 2 1107
死守一世寂寞
死守一世寂寞 2020-12-11 21:11

If you have 2 arrays classical and pop:

classical=[\"Beethoven\",\"Mozart\",\"Tchaikovsky\"];
pop=[\"Beatles\",\"Corrs\",\"Fleetwood Mac\",\"Status Quo\"];
<         


        
2条回答
  •  半阙折子戏
    2020-12-11 22:18

    Use the Array class concat() method to combine them on a new variable:

    var all = classical.concat(pop);
    

提交回复
热议问题