Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Increment (++) and Decrement (--) Operators

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

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

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


Any variable.


Any variable.

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.

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.

© 2015 Microsoft