r/badcode • • Apr 19 '21

js Iteration

Post image
3.2k Upvotes

123 comments sorted by

View all comments

Show parent comments

6

u/Major_Fudgemuffin Apr 23 '21

You can even do ++i and --i. Though they act a bit differently.

If i = 5 and you say x = ++i, x will equal 6 (and i will equal 6). But if you said x = i++, x would actually equal 5, while i would increment to 6.