What is the difference between ++i vs. i++ ?

Pre/Post Increment/Decrement Operators Explained.

Increment Operator ++

for (var i = 0; i < 3; i++) {
console.log(i);
}
Output:
0 // i = 0, increment by 1 => i = 1
1 // i = 1, increment by 1 => i = 2
2 // i = 2, increment by 1 => i = 3, i is not < 3, loop ends

Pre-increment vs. Post-increment

// Increment operator
// Pre-increment: x is incremented by 1, then y is assigned the value of x
x = 1;
y = ++x; // x is 2, y is also 2

// Post-increment: y is assigned the value of x, then x is incremented by 1
x = 1;
y = x++; // x is 2, y is 1

// Decrement operator
// Pre-decrement: x is decremented by 1, then y is assigned the value of x
x = 1;
y = --x; // x is 0, y is also 0

// Post-decrement: y is assigned the value of x, then x is decremented by 1
x = 1;
y = x--; // x is 0, y is 1
# Pre-increment: y = ++x
x = 1
x = x + 1 # x is now 2 (or "x += 1" in Python and Ruby)
y = x # y is also 2

# Post-increment: y = x++
x = 1
y = x # y is 1
x = x + 1 # x is now 2