Junior JavaScript

What is the rest operator?

The rest operator ... collects multiple arguments into an array.

Example:

function sum(...nums) {

return nums.reduce((a, b) => a + b);

Follow me on LinkedIn:

console.log(sum(1, 2, 3)); // 6

More from JavaScript Tutorial

All questions for this course