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.