Increment value (++) (Operator/postfix)

Pre or post incrementing operator.

Availability:

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

The operand is incremented by one.

A prefixing incrementor will add 1 to the operand value before it is used in an expression.

A post-fixing incrementor will add 1 to the operand after it is used in an 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:Add then assign (+=), Additive expression, Additive operator, Decrement value (--), Postfix expression, Postfix increment (++), Prefix expression

Cross-references:

ECMA 262 edition 2 - section - 11.3.1

ECMA 262 edition 3 - section - 11.3.2