JS Quiz

Question: What is the result of 10,2; in JavaScript?

When you write 10,2; in JavaScript, this is using the comma operator. The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.

So, in this case:

  • 10 is evaluated first but discarded.
  • 2 is then evaluated and returned as the result.

Therefore, the result of 10, 2 in JavaScript is 2.