Suppose we have such a function with
5
parameters:
function func(num1, num2, num3, num4, num5) {
return num1 + num2 + num3 + num4 + num5;
}
We can use spread
to pass one
array to this function:
func(...[1, 2, 3, 4, 5]);
But this is optional!
You can pass two arrays:
func(...[1, 2], ...[3, 4, 5]);
You can pass part of the parameters in the ordinary way, and part - using spread:
func(1, 2, ...[3, 4, 5]);
Or like this:
func(1, ...[2, 3, 4], 5);
Without running the code, determine what will be output to the console:
function func(n1, n2, n3, n4, n5, n6, n7, n8) {
return (n1 + n2 + n3 + n4) * (n5 + n6 + n7 + n8);
}
console.log( func(1, ...[2, 3, 4], 5, ...[6], ...[7, 8]) );