+ 3

What is the output of this code & why?

let x = 5; x += x++; console.log(x);

8th Sep 2020, 3:25 PM
Noob Programmer
Noob Programmer - avatar
5 Answers
+ 7
x += x++; 5 += 5++; Since x++ is a post increment operation, the value will be first assigned to x. So you get the result as 10.
8th Sep 2020, 3:31 PM
Avinesh
Avinesh - avatar
+ 5
I think you have some ideas going on in your mind, about what happens and why. Maybe you should tell what you think of it first, then others here can suggest correction, in case any was necessary.
8th Sep 2020, 3:31 PM
Ipang
+ 5
Ipang well, I think the output is 11. Am I right?
8th Sep 2020, 3:32 PM
Noob Programmer
Noob Programmer - avatar
+ 4
Abir Sheikh I guess now you know 😁
8th Sep 2020, 3:39 PM
Ipang
+ 2
Ipang 😂
9th Sep 2020, 12:03 AM
Noob Programmer
Noob Programmer - avatar