es6 merge arrays code example
Example 1: javascript array concat spread operator
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2]
Example 2: es6 concat array
let fruits = ["apples", "bananas"];
let vegetables = ["corn", "carrots"];
let produce = [...fruits, ...vegetables];
Example 3: javascript merge array
let array1 = ["a", "b"]
let array2 = ["1", "2"]
let combinedArray = array1.concat(array2);
let array1 = ["a", "b"]
let array2 = ["1", "2"]
let combinedArray = [...array1, ...array2]
Example 4: javascript merge two array with spread operator
const a = ['to', 'code'];
const b = ['learning', ...a, 'is', 'fun'];
console.log(b);