1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Refactor Array concat() Operations to Use the ES6 Spread Operator

    javascriptJavaScript

    In this video, we take a quick look at refactoring usages of Array.prototype.concat to make use of the ES6 array spread operator. For example, we can refactor towards simple append and prepend statements such as [...array, value] or [value, ...array] or combine multiple spread operations to achieve insert via [...leftSide, value, ...rightSide].

    Bonus tip: [...someArray] can be used to quickly make a shallow copy of an array to avoid mutation for many common array operations.