I've read about the comma operator in JS but I am not sure whether this operator is used in expressions like this:
var a, b, c;
Is this the comma operator at work or is the comma used here just part of the syntax for declaring multiple variables and thus nothing to do with the comma operator?
Similarly, what about code that declares an array literal:
var x = [ 1, 2, 3 ];
It seems to me that comma operator syntax requires parentheses around the expression, for example:
x = (2, 3);
but this was not explicitly noted in the MDN article. If this is the case then is it true that the first two snippets here are not using the comma operator because there are no parentheses around it?
var x = [1,2,3]is not comma operator. But, something like:x[1,2,3] = 'value'uses the the comma operator. So, it doesn't always require parentheses. It is same asx[3] = 'value'.