Day 026 - Arithmetic Operators (Part 3)


You can also increment and decrement values.

You can use either of these as a prefix or postfix operator.

var i = 10;

var a = ++i;
var b = i++;
var c = --i;
var d = i--;

Increment prefix: a would be equal to 11 and i equal to 11.

Increment postfix: b would be equal to 11 and i equal to 12.

Decrement prefix: c would be equal to 9 and i equal to 9.

Decrement postfix: d would be equal to 9 and i equal to 8.

Demo.