+ 1
X++ & ++X i cant understand it
Hi Please I Need Some One ..explain To Me The Difference Between X++ & ++X OR X-- & --X
5 Réponses
+ 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.
+ 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)
+ 1
var x = 5;
var y = x++;
result:
x=6;
y=5;
///////////////////////
var x=5;
var y = ++x;
result:
x=6;
y=6;
0
Var x=1;
Console. Log(x++ + ++x +x) ;