How does the comma operator work in js?

var c = (a,b);

The above uses the comma operator. It evaluates as the value of its right-hand side (i.e. b).


var c = a,b;

This does not use the comma operator.

The comma character here forms part of the var expression which takes a comma-separated list of variables to create in the current scope, each of which can have an optional assignment.

It is equivalent to:

var c = a;
var b;