DEV Community

Cover image for [SOLVED] How To Merge Arrays Using Spread Operator?
Islam Sayed
Islam Sayed

Posted on

2 2

[SOLVED] How To Merge Arrays Using Spread Operator?

Spread Operator is of a great use in case of dealing with arrays and objects. Here how to merge two arrays using it.

const arr1 = [1, 2];
const arr2 = [3, 4];

const arr3 = [...arr1, ...arr2]; // [1, 2, 3, 4]

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more