πŸ”₯ NEW Code Tidbit Every Week πŸ”₯

# Combine Multiple Arrays Using Spread

Combine Multiple Arrays using ES6 Spread β€¬πŸ€©

Instead of using concat() to concatenate arrays, try using the spread syntax to combine multiple arrays into one flattened arrayπŸ‘

let veggie = ['πŸ…', 'πŸ₯‘'];
let meat = ['πŸ₯“'];

// Old Way
let sandwich = veggie.concat(meat, '🍞');
console.log(sandwich); // [ 'πŸ…', 'πŸ₯‘', 'πŸ₯“', '🍞' ]

// ES6 Way
let sandwich2 = [...veggie, ...meat, '🍞'];
console.log(sandwich2); // [ 'πŸ…', 'πŸ₯‘', 'πŸ₯“', '🍞' ]

# Resources


Related Tidbits