+ 1

Assignment and increment

Explain Why following code alerts 5 and not 6. I know it applies assignment first and increment next. https://code.sololearn.com/WfFESf1hUsox/?ref=app

29th Nov 2018, 2:49 AM
Sindhe Kishan
Sindhe Kishan - avatar
4 Respostas
+ 7
https://stackoverflow.com/questions/7911776/what-is-x-after-x-x
29th Nov 2018, 10:43 AM
Rstar
Rstar - avatar
29th Nov 2018, 6:04 AM
Rstar
Rstar - avatar
+ 3
var x=5; x= x++; //x++ does not increment because the value here is: 5
29th Nov 2018, 1:25 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 2
In the post he said x++ evaluates to x and hence old value is assigned to x. But after assignment increment operator should execute and increase the value of x by 1 right?
29th Nov 2018, 10:15 AM
Sindhe Kishan
Sindhe Kishan - avatar