+ 1
How is the output 99... I can only get 100 on paper
var x= 9; var y= x++; console.log(++x*y);
2 odpowiedzi
+ 2
var y = x++;
Here 'y' is assigned 9 and not 10.
The value of 'x' is first assigned and then incremented. After the statement is executed, the value of x becomes 10.
console.log(++x*y);
Here 'x' is again incremented and becomes 11 but 'y' remains 9 so the output is 11*9 = 99.
+ 3
in y only 9 is stored ,and x value is incremented later
Now x is 10 but using ++x first increases x value
And it is 11 now
So 11*9=99