Tuesday, 16 January, 2018 UTC


Summary

In this video, we take a quick look at refactoring usages of [Array.prototype.concat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) to make use of the [ES6 array spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/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.