The rest parameter of ECMA Script 6

In below ECMA Script 6 example we are going to use the rest parameter to pass in an array to a function and calculate the total value.

function addSum(a, b, c, d, e) {
	return a + b + c + d + e;
}

let sum = addSum(1, 2, ...[3, 4, 5]);

console.log(sum);

The outcome will be 15!

Like this post? Kindly share!