const arr1 = ['a', 'b', 'c']; const arr2 = ['1', '2', '3']; // Using .concat() console.info(arr1.concat(arr2)); // ["a","b","c","1","2","3"] // Using spread operators console.info([...arr1, ...arr2]); // ["a","b","c","1","2","3"] // This works too: console.info(['a', 'b', 'c', ...arr2]); // ["a","b","c","1","2","3"] // Using Array.of console.info(Array.of(...arr1, ...arr2)); // ["a","b","c","1","2","3"] // With reduce console.info(arr2.reduce(function(array,value) { array.push(value); return array; }, arr1)); // ["a","b","c","1","2","3"]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter