Difference Between ++a And a++ In JavaScript?

yns - Jun 22 - - Dev Community

The ++ is responsible of the increment of the number value by 1 . But have you wondered what is the difference between putting it before or after?

  • ++a : returns the value after the increment.

  • a++ : returns the value before the increment.

Let's take an example:

let a=0;
a++;
++a;

the output will be:
output->0
1

. . .