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"]
1const letters = ['a', 'b', 'c'];
2const numbers = [1, 2, 3];
3
4const newArray = letters.concat(numbers);
5// newArrat is ['a', 'b', 'c', 1, 2, 3]
1const letters = ['a', 'b', 'c'];
2const numbers = [1, 2, 3];
3
4letters.concat(numbers);
5// result in ['a', 'b', 'c', 1, 2, 3]
6