DEV Community

Mehul Lakhanpal
Mehul Lakhanpal

Posted on • Originally published at codedrops.tech

Merge two arrays

const a = [1, 2, 3];
const b = [4, 5, 6];

// 1. .concat()
console.log(a.concat(b)); // [ 1, 2, 3, 4, 5, 6 ]

// 2. spread operator
console.log([...a, ...b]); // [ 1, 2, 3, 4, 5, 6 ]
Enter fullscreen mode Exit fullscreen mode

Thanks for reading πŸ’™

Follow @codedrops.tech for daily posts.

Instagram ● Twitter ● Facebook

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript

codedrops.tech

Discussion (0)