es6 array merge code example
Example 1: merge array in js
var array1 = ["Rahul", "Sachin"];
var array2 = ["Sehwag", "Kohli"];
var output = array1.concat(array2);
console.log(output);
var array1 = ["Dravid", "Tendulkar"];
var array2 = ["Virendra", "Virat"];
var output = [...array1, ...array2];
console.log(output);
Example 2: es6 concat array
let fruits = ["apples", "bananas"];
let vegetables = ["corn", "carrots"];
let produce = [...fruits, ...vegetables];
Example 3: javascript merge two array with spread operator
const a = ['to', 'code'];
const b = ['learning', ...a, 'is', 'fun'];
console.log(b);