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-decrement and post-decrement unary operator that subtracts 1 from the expression. The pre-decrement form of the operator (--expression) subtracts 1 from expression and returns the result. The post-decrement form of the operator (expression--) subtracts 1 from the expression and returns the initial value of expression (the value prior to the subtraction).
Sample
The pre-decrement form of the operator decrements x to 2 (x - 1 = 2), and returns the result as y:
x = 3;
y = --x;
//both y and x are equal to 2
The post-decrement form of the operator decrements x to 2 (x - 1 = 2), and returns the original value of x as the result y:
x = 3;
y = x--;
//y is equal to 3, x is equal to 2