++i vs i++ js code example
Example 1: javascript decrement
// Increment
let a = 1;
a++;
++a;
// Decrement
let b = 1;
b--;
--b;
Example 2: javascript diffence between a++ and ++a
// ++i returns the value of i after it has been incremented. i++ returns the value of i before incrementing.
// When the ++ comes before its operand it is called the "pre-increment" operator, and when it comes after it is called the "post-increment" operator.
// This distinction is only important if you do something with the result.
var i = 0, j = 0;
alert(++i); // alerts 1
alert(j++); // alerts 0