Tip 7 | Mold Arrays with the Spread Operator |
In this tip, you’ll learn how to simplify many array actions with the spread operator.
As you’ve seen, arrays provide an incredible amount of flexibility for working with data. But the number of methods that an array contains can be confusing, and it could lead you to some problems with mutations and side effects. Fortunately, the spread operator gives you a way to create and manipulate arrays quickly with minimal code.
The spread operator, symbolized with three dots (...), may be the most widely used new feature in JavaScript. You’re likely to find it in nearly every file containing ES6+ syntax.
That said, it’s hard to take the spread operator seriously. I certainly didn’t. What it does is so mundane: ...
Get Simplifying JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.