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.

InstagramTwitterFacebook

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

codedrops.tech

Top comments (0)