What does a comma do in JavaScript expressions?

The comma operator evaluates both of its operands (from left to right) and returns the value of the second operand.

Source: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special_Operators/Comma_Operator

For example, the expression 1,2,3,4,5 evaluates to 5. Obviously the comma operator is useful only for operations with side-effects.

console.log(1,2,3,4,5);
console.log((1,2,3,4,5));


Some more to consider:

console.log((0, 9));
console.log((9, 0));
console.log(("foo", "bar"));


The comma operator evaluates both of its operands (from left to right) and returns the value of the second operand.

https://stackoverflow.com/a/3561056/5934465

It should be like this!

The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator