Spread Operator

an introduction to spread operator, limitations of rest parameter and their solution using the spread parameter

In ES5, we often used the apply method to call a function with a variable number of arguments. The spread operator makes it possible to achieve the exact same thing in a more compact way.

Suppose you would like to write a method that returns the sum of its arguments. Let’s write this function in ES5:

Get hands-on with 1400+ tech skills courses.