Here are two ways to combine your arrays and return a NEW array. I like using the Spread operator. But if you need older browser support, you should use Concat.
// 2 Ways to Merge Arrays
const cars = ['🚗', '🚙']; const trucks = ['🚚', '🚛'];
// Method 1: Concat const combined1 = [].concat(cars, trucks);
// Method 2: Spread const combined2 = [...cars, ...trucks];
// Result// [ '🚗', '🚙', '🚚', '🚛' ]
0 comments:
Post a Comment