Question:

What does the following function print to the console?

function sum(a, b) {
  return a + b;
}
console.log(sum(1, 2, 3, 4));

Answer:

3

When too many arguments are supplied to a function they are simply ignored. The sum() function only takes 2 arguments so the extra arguments (3 and 4) are ignored in this example.


Keywords:

© 2017 QuizBucket.org