Decrement value (--) (Operator/postfix)

Pre or post decrementing operator.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:---anOperand
-anOperand--
Argument list:anOperandA numeric value that can be decremented

The operand is decremented by one.

A pre-fixing decrementor will subtract 1 from the operand value before it is used in the expression.

A post-fixing decrementor will subtract 1 from the operand after it is used in the expression.

Be careful how you use this pre/post placement as you can easily generate 'off by one' errors in your algorithms by placing the operator on the wrong side of the operand.

This operator is more or less functionally equivalent to:

anOperand -= 1

which is equivalent to:

anOperand = anOperand - 1

See also:Additive expression, Additive operator, Increment value (++), Negation operator (-), Postfix decrement (--), Postfix expression, Postfix increment (++), Prefix decrement (--), Prefix expression, Prefix increment (++)

Cross-references:

ECMA 262 edition 2 - section - 11.3.2

ECMA 262 edition 3 - section - 11.3.2