snippet

How to combine two arrays in Javascript with concat function

// First exemple
const firstArray = [0, 1, 2];
const secondArray = [3, 5, 7];
const combined = firstArray.concat(secondArray); // Return [0, 1, 2, 3, 5, 7]

// Second exemple with ES6 syntaxe
const combined = [...firstArray, ...secondArray];
Related snippets