3 Ways To Concat Arrays In Javascript
[code lang=”js”]
const one = [‘a’, ‘b’, ‘c’];
const two = [‘d’, ‘e’, ‘f’];
const three = [‘g’, ‘h’, ‘i’];
// Way #1
const way1 = one.concat(two, three);
// Way #2
const way2 = [].concat(one, two, three);
// Way #3
const way3 = […one, …two, …three];
// > ["a", "b", "c", "d", "e", "f", "g", "h", "i"]
[/code]