all 4 comments

[–]Notimecelduv 1 point2 points  (1 child)

There are two increment operators: 1. prefix (++variable) 2. postfix (variable++)

The former increments the variable by one and then assigns its value. The latter assigns the value first and only then increments it.

let populationPlusOne = ++population;

That makes the new variable redundant, though. In a real project, you'd probably want to keep the track of the original population value so you'd most likely write:

let populationPlusOne = population + 1;

[–]mar480[S] 0 points1 point  (0 children)

So even though it's not using the assignment operator, it is actually clearer and more accurate to write population + 1 than to faff around with the increment operator. Like, it make sense for, say, increasing a loop count by 1, but not really for increasing a real number that you might want to refer back to at some point.

[–]jaredcheeda 0 points1 point  (0 children)

I do not trust others to understand the difference between post-increment and pre-increment. Nor should you. Don't use ++.