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--);
3 Respostas
+ 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!
+ 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!
0
hi Everyton,
for that conclusion, we can assign y=x instead of y=x++. both will result the same correct.