Operators > -- (decrement)

-- (decrement)

Syntax

--expression
expression--

Arguments

expression A variable, number, element in an array, or property of an object.

Description

Operator; 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 the expression (the result prior to the subtraction).

Player

Flash 4 or later.

Example

The pre-decrement form of the operator decrements x to 2 (x - 1 = 2), and returns the result as y:

x = 3;

y = --x

The post-decrement form of the operator decrements x to 2 (x - 1 = 2), and returns the original value (x = 3) as the result y:

If x = 3;

y = x--