7 ES6 Spread Operator Tricks Every Developer Should Know
Preface
ES6 provides a new operator called the spread operator, which is composed of three points (…).
The spread operator allows you to expand the elements of an iterable object, such as map, array, set and object. That even allows us to write less and do more.
Example:
In this article, I want to teach you 7 spread operator tricks.
1. A better way to use the array’s push() method
We all know that the push() method supports passing multiple indeterminate parameters.
Usually, we use the apply() method to fill the array, but that is not convenient after all.