0

Why is it, that this function returns 2021 instead of 2020 - is there any explanation on this?

function printNumber(num) {
 return num;
}

printNumber((2020, 2021));

Malthe
  • 11
  • 3
  • Basically comma operator evaluates operands from left to right and return the last evaluated operand in the function the last operand will be passed which is 2021 and that is the number your printNumber() is returning – Yatin Gaikwad Aug 19 '20 at 06:34
  • That's cool to know, thanks for the answer! – Malthe Aug 19 '20 at 22:55

0 Answers0