I've defined the function prod which makes use of ES6's default arguments and destructuring:
function prod([a, b, c] = [1, 2, 3]) {
console.log(a * b * c);
}
When called without arguments, it logs 6 to the console as expected.
prod() // 6
When called with an array of arguments, it logs the correct product:
prod([2, 3, 4]) // 24
When called with a number of arguments, it throws an error:
prod(2, 3, 4) // Uncaught TypeError: undefined is not a function(…)
Why does it throw an undefined is not a function error?
Edit
I understand why it throws an error. What I don't understand is why it throws that particular error.
prod([2,3,4])?undefined is not a function. I'll update the question.