Expand Minimize
4 out of 5 rated this helpful - Rate this topic

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

JavaScript - Internet Explorer 10

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

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

Any variable.

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. Also supported in Windows Store apps. See Version Information.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.