[Solved] What does this shorthand mean in JavaScript? [duplicate]


It’s the decrement operator. The value of q is decreased by 1 each time q-- is evaluated but, importantly, the value is returned before the decrement.

So, the loop above will continue until q=1 but the value used inside the loop during this final iteration will be q=0.

In layman’s terms: q-- means “Give me the value of q then decrease it by 1 directly afterwards”.

2

solved What does this shorthand mean in JavaScript? [duplicate]