merge two arrays spread operator code example

Example 1: javascript array concat spread operator

const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]

Example 2: javascript merge two array with spread operator

const a = ['to', 'code'];
const b = ['learning', ...a, 'is', 'fun']; 
console.log(b); //> ['learning', 'to', 'code', 'is', 'fun']

Example 3: Merging Or Copying Arrays Using Spread Operator

let techlist1= ['spring', 'java'];
 let techlist2= ['javascript', 'nodejs', 'mongo'];
 let fullstacklist= […techlist1, …techlist2];
 console.log(fullstacklist);