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
1// ES5 version use Array.concat:
2let array1 = ["a", "b"]
3let array2 = ["1", "2"]
4let combinedArray = array1.concat(array2);
5// combinedArray == ["a", "b", "1", "2"]
6
7// ES6 version use destructuring:
8let array1 = ["a", "b"]
9let array2 = ["1", "2"]
10let combinedArray = [...array1, ...array2]
11// combinedArray == ["a", "b", "1", "2"]
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.concat(array2);
4
5console.log(array3);
6// expected output: Array ["a", "b", "c", "d", "e", "f"]
7
1let fruits = ["apples", "bananas"];
2let vegetables = ["corn", "carrots"];
3let produce = [...fruits, ...vegetables];
4//["apples","bananas","corn","carrots"]