Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Comma Operator (,) (JavaScript)

Causes two expressions to be executed sequentially.

expression1, expression2

expression1

Any expression.

expression2

Any expression.

The , operator causes the expressions to be executed in left-to-right order. A common use for the , operator is in the increment expression of a for loop. For example:

j=25;
for (i = 0; i < 10; i++, j++)
{
   k = i + j;
}

The for statement allows only a single expression to be executed at the end of every pass through a loop. The , operator allows multiple expressions to be treated as a single expression, so both variables can be incremented.

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft