The spread operator (modern default)
const a = [1, 2];
const b = [3, 4];
const merged = [...a, ...b];
console.log(merged); // [1, 2, 3, 4]
You can spread as many arrays as you like and even drop extra values in between, such as [...a, 99, ...b].
Using concat()
const merged = a.concat(b);
console.log(merged); // [1, 2, 3, 4]
concat also returns a new array and reads clearly when you prefer a method call over spread syntax.
Merge without duplicates
const a = [1, 2, 3];
const b = [3, 4, 5];
const unique = [...new Set([...a, ...b])];
console.log(unique); // [1, 2, 3, 4, 5]
A Set only stores unique values, so spreading the combined array through one removes any repeats.
Add one array onto another in place
a.push(...b);
console.log(a); // [1, 2, 3, 4]
Which method should you use?
- Spread — the everyday choice for a new combined array.
- concat() — when you prefer a clear method name.
- Set — when you need to drop duplicates.
- push(...b) — when you want to extend an existing array in place.
Frequently asked questions
Does spread copy nested objects?
No. The spread operator makes a shallow copy, so nested objects and arrays are still shared by reference. Clone them separately if you need a deep copy.
Is concat or spread faster?
For normal array sizes the difference is negligible. Pick whichever reads more clearly to you; spread is the more common modern style.
Learn the spread operator and more in our free JavaScript course.