spread operator in Javascript ES6

Posted in Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

The spread operator in Javascript ES6 uses three dots …

spread operator

It also returns 15 to the browser.   Except that the dot-dot-dot is in the caller and not in the function definition.  The function “adder” as defined takes exactly three values.   But the caller has an array “numbers” containing three values.  The spread operator take each of these values and turns them into three values that the function is expecting.

Spread operators make it more convenient to work with arrays.  For example…

spread operator in arrays

More ES6 features here.