Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

JScript Comma Operator (,)

Causes two expressions to be executed sequentially.

Syntax: JScript Comma Operator (,)

expression1, expression2

Arguments: JScript Comma Operator (,)

expression1

Any expression.

expression2

Any expression.

Remarks: JScript Comma Operator (,)

The , operator causes the expressions on either side of it to be executed in left-to-right order, and obtains the value of the expression on the right. The most common use for the , operator is in the increment expression of a for loop. For example:

for (i = 0; i < 10; i++, j++)

{

k = i + j;

}

The for statement only allows a single expression to be executed at the end of every pass through a loop. The , operator is used to allow multiple expressions to be treated as a single expression, thereby getting around the restriction.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.