Homework Assignment #16: Rest and Spread

What are the differences between rest and spread?

Rest parameters

From the definition we saw earlier, rest parameters collect all the remaining elements into an array.

Code Editor & preview

Note: Rest parameters have to be at the last argument. This is because it collects all remaining/ excess arguments into an array.

Spread Operators

Spread operator helps us to expand the strings or array literals or object literals.

Code Editor & preview

Summary :