Increment (++) and Decrement (--) Operators (JavaScript)

The increment operator increments, and the decrement operator decrements the value of a variable by one.

Syntax


      result = ++variable  
result = --variable  
result = variable++  
result = variable--  

Parameters

result
Any variable.

variable
Any variable.

Remarks

If the operator appears before the variable, the value is modified before the expression is evaluated. If the operator appears after the variable, the value is modified after the expression is evaluated. In other words, given j = ++k;, the value of j is the original value of k plus one; given j = k++;, the value of j is the original value of k, which is incremented after its value is assigned to j.

Requirements

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

See Also

Operator Precedence
Operator Summary (JavaScript)