++ (increment)

SWiSH Player Support
SWF4 or later - Supported Internally

Syntax
++expression
expression++

Arguments
expression can be a variable, number, element in an array, or the property of an Object.

Returns
++expression returns expression + 1.
expression++ returns expression.

Description
Operator (arithmetic); a pre-increment and post-increment unary operator that adds 1 to expression. The expression can be a variable, element in an array, or property of an Object. The pre-increment form of the operator (++expression) adds 1 to expression and returns the result. The post-increment form of the operator (expression++) adds 1 to expression and returns the initial value of expression (the value prior to the addition).
The pre-increment form of the operator increments x to 2 (x + 1 = 2), and returns the result as y:
x =  1 ;
y = ++x

//y is equal to 2, x is equal to 2

The post-increment form of the operator increments x to 2 (x + 1 = 2), and returns the original value of x as the result y:
x =  1 ;
y = x++;

//y is equal to 1, x is equal to 2

Sample
The following example uses ++ as a post-increment operator to make a while loop run five times.
i =  0 ;
while (i++ <  5 ) {
trace("this is execution " + i);
}


This example uses ++ as a pre-increment operator .
var  a = [];
var  i =  0 ;
while  (i <  10 )  {
a.push(++i);
}
trace(a.join()); 
// displays "1,2,3,4,5,6,7,8,9,10" in the 'Debug' window

The following example uses ++ as a post-increment operator .
var  a = [];
var  i =  0 ;
while  (i <  10 )  {
a.push(i++);
}
trace(a.join());
  // displays "0,1,2,3,4,5,6,7,8,9" in the 'Debug' window.