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
Show parent comment
2
u/busres Apr 10 '26
I'm the opposite. Standalone
i++just feels wrong to me. In comparison to++i, the semantics suggest we have some attachment to (i.e. need to save) the original value when we don't. Maybe it's because I'm from the PDP-11 generation, when instruction word-count was potentially more of an issue.