I'm trying to get my head around the reason JS picks the last element (8
):
var values = (null, 7, null, 8);
console.log(values);
// Output: 8
console.log
and alert
behaves the same so I assume it's something to do with the language itself.
I'm trying to get my head around the reason JS picks the last element (8
):
var values = (null, 7, null, 8);
console.log(values);
// Output: 8
console.log
and alert
behaves the same so I assume it's something to do with the language itself.
This one also explained beautifully link
The comma operator evaluates both of its operands (from left to right) and returns the value of the second operand