I’ve been bitting my nails for this one, The spread syntax … is all kinds of awesome, but what is it and what does it replace ?
See the Pen ES6 Sampler - Spread Operator Pt1. by Eugenio - Keno - Leon (@k3no) on CodePen.
More than anything, the spread syntax brings clarity and a cool way of using enumerable arguments in a function call. There seems to be more, you can also use them in array literals, but what does that entail…
See the Pen ES6 Sampler - Spread Operator Pt2. by Eugenio - Keno - Leon (@k3no) on CodePen.
Notice that depending how you use those 3 dots it is either a spread ( wave your hand like you are spreading something on bread), or Rest ( as in the rest of), Operator.
See the Pen ES6 Sampler - Spread Operator Pt3. by Eugenio - Keno - Leon (@k3no) on CodePen.
One of the coolest things you can do with the dots, are Rest Parameters, so you can define a function with an unlimited/unknown number of parameters.
See the Pen ES6 Sampler - Spread Operator Pt4 by Eugenio - Keno - Leon (@k3no) on CodePen.
You can use the spread syntax to simplify your javascript in a lot of places and cases, each one has it’s nuances, but overall make writing clear JS easier.
Spread Syntax has many faces all of them are useful
Best,
Keno.