1let arr1 = [0, 1, 2];
2let arr2 = [3, 5, 7];
3let primes = arr1.concat(arr2);
4
5// > [0, 1, 2, 3, 5, 7]
1//for ES5
2var array1 = ["Rahul", "Sachin"];
3var array2 = ["Sehwag", "Kohli"];
4
5var output = array1.concat(array2);
6console.log(output);
7
8//for ES6, we use spread operators to concat arrays
9
10var array1 = ["Dravid", "Tendulkar"];
11var array2 = ["Virendra", "Virat"];
12
13var output = [...array1, ...array2];
14console.log(output);
15
1const array1 = ["Vijendra","Singh"];
2const array2 = ["Singh", "Shakya"];
3const array3 = [...array1, ...array2];
1var array1 = ["Vijendra", "Singh"];
2var array2 = ["Singh", "Shakya"];
3
4console.log(array1.concat(array2));
1const array1 = ['a', 'b', 'c'];
2const array2 = ['d', 'e', 'f'];
3const array3 = [...array1, ...array2];
4
5console.log(array3);
6// expected output: Array ["a", "b", "c", "d", "e", "f"]
1//ES6 using the spread operator
2const itemsA = [ 'Lightsaber', 'Mockingjay pin', 'Box of chocolates' ];
3const itemsB = [ 'Ghost trap', 'The One Ring', 'DeLorean' ]
4const allItems = [ ...itemsA, ...itemsB ];