Comma Operator

Top  Previous  Next

Operator:  ,


expression1 , expression2


The comma operator evaluates both expressions. The result of the operator is the value of expression2. Since the value of expression1 is discarded, it is only useful if it has side effects.


The comma operator is not allowed where comma-separated lists can occur. This includes variable initializers in the var statement, function call argument lists, and array literals.