//ES6 using the spread operatorconst itemsA =['Lightsaber','Mockingjay pin','Box of chocolates'];const itemsB =['Ghost trap','The One Ring','DeLorean']const allItems =[...itemsA,...itemsB ];
let arr1 =['1','2'];let arr2 =['3','4'];let combarr =[].concat(arr1);//define new variable, empty array then concatenating arr1 to it
combarr = combarr.concat(arr2);//combarr = itself, then concatenating arr2 to the endconsole.log(combarr);//Expected output: ['1','2','3','4']
<!DOCTYPE html><html><body><p>We will see after clicking the button how two array will join</p><button onclick="concateTwoArray()" id="btnClick">Click</button><p id="pId"></p><script>functionconcateTwoArray(){var twoDay=["Sunday","Monday"];var fiveDay=["Tuesday","Wednsday","Thursday","Friday","Saturday"];var totalDay = twoDay.concat(fiveDay);document.getElementById("pId").innerHTML= totalDay ;}</script></body></html>