+ 1

X++ & ++X i cant understand it

Hi Please I Need Some One ..explain To Me The Difference Between X++ & ++X OR X-- & --X

19th Sep 2017, 7:15 PM
Haitham Alqutob
Haitham Alqutob - avatar
4 Answers
+ 5
++x increments the value of x and then returns x x++ returns the value of x and then increments example: x=0; y=0; a=++x; b=y++; after the code is run a=1 but b=0.
19th Sep 2017, 8:04 PM
Aqua9
Aqua9 - avatar
+ 3
var x = 5; console.log( x++ ) // output x=5 console.log (x) //output x=6 console.log(++x) //output x=7 console.log(x) //output x=7 console.log(x++ ) is same to console.log(x); x=x+1; console.log(++x) is same to x=x+1; console.log(x)
19th Sep 2017, 7:23 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 1
var x = 5; var y = x++; result: x=6; y=5; /////////////////////// var x=5; var y = ++x; result: x=6; y=6;
19th Sep 2017, 8:04 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
0
Var x=1; Console. Log(x++ + ++x +x) ;
24th Jan 2022, 10:03 AM
Shweta Chougule