Export (0) Print
Expand All
4 out of 6 rated this helpful - Rate this topic

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--
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, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.