0

What will be the answer for the following ? I couldn't understand x++ & ++x

var x=5; var y=x++; document.write(x++ + y--);

31st Jan 2017, 12:45 PM
Sathish C
3 Respuestas
+ 1
with ++x you will increment the value of x before assign it to y, with x++ you will use the value before increment, so when you do var y = x++ the var y will have the value 5 and x will have the value 6. PS: sorry for my bad english, i'm brazilian!
31st Jan 2017, 3:41 PM
N1NJ4BR
+ 1
yes the var y will have the same value, but, if you use x++ you increment the value of x, if you don't use, x will continue with the same value. Again, sorry for my english!
31st Jan 2017, 7:52 PM
N1NJ4BR
0
hi Everyton, for that conclusion, we can assign y=x instead of y=x++. both will result the same correct.
31st Jan 2017, 7:32 PM
Sathish C