Sometimes, we want to join or combine two arrays to concatenate into one array with JavaScript.
In this article, we’ll look at how to join or combine two arrays to concatenate into one array with JavaScript.
How to join or combine two arrays to concatenate into one array with JavaScript?
To join or combine two arrays to concatenate into one array with JavaScript, we can use the spread operator.
For instance, we write
const a = ["a", "b", "c"];
const b = ["d", "e", "f"];
const c = [...a, ...b];
to combine the entries in a
and b
into array c
by spreading the values in them into c
with ...
.
Therefore, c
is
["a", "b", "c", "d", "e", "f"]
Conclusion
To join or combine two arrays to concatenate into one array with JavaScript, we can use the spread operator.