There is a common practice in JavaScript where i++
is used to increment the value of a variable by one. This is commonly seen in loops like the following:
for (var i=1; i<=10; i++) {
console.log(i);
}
However, what happens when we use ++i;
instead? How does it differ from using the --
operator for subtraction?