+ 1
++x and x++ in js
Without a var to point to x++ and ++x, what is the difference between them?
2 Answers
+ 1
++x; // prefix
x++; //postfix
Prefix increments the value, and then proceeds wirh the expression.
Postfix evaluates the expression and then performs the incrementing.
Prefix example :
int x = 3;
int y = ++x;
// x=4, y=4
Postfix example :
int x = 3;
int y = x++;
// x=4, y=3
+ 1
Thank you for your explanation. This issue is rather confusing. Now at least i understand better



