r/learnjavascript • u/grave4us • Apr 10 '26
Increment/decrement trouble
I don't quite understand how increment and decrement operators work—specifically, under what conditions switching between postfix and prefix forms alters or returns the value, and in which cases they behave identically.
(im using the google translator, if anything is unclear, please ask for clarification.) Thank you!
5
Upvotes
View all comments
8
u/Aggressive_Ad_5454 Apr 10 '26
These operators come from the C language, and were designed to exploit particular addressing modes on PDP-11 computers.
The classic way we old-timers copied null terminated text strings was
while (*dest++ = *src++) {}until we figured out how astonishingly insecure that is.That line of code means…
The joke is this:
C++means “add one to C and return the previous value”.