example 1:var i = 1;var j = ++i; // 自加运算符在i之前: j 等于 2; i 等于 2var k = i++; // 自加运算符在i之后: k 等于 2; i 等于 3
example 2:
var i = 42;alert(i++); // shows 42alert(i); // shows 43i = 42;alert(++i); // shows 43alert(i); // shows 43
example 3:
a = 5;b = 5;c = ++a;d = b++;
a
is 6, b
is 6, c
is 6 and d
is 5.
example 4:
var j = 2;console.log(j++); // 2console.log(j); // 3var k = 2;console.log(++k); // 3console.log(k); // 3