+ 3

Who will help me understand this...

var x=1,y=1; document.write(++x==2 && y++ ==1); document.write(x,y); X=2,y=2 var x=1,y=1; document.write(++x==3 && y++ ==1); document.write(x,y); X=2,y=1

27th Feb 2021, 11:36 AM
Danny Wanyoike
Danny Wanyoike - avatar
4 ответов
+ 5
what could surprise you is the last document.write: as ++x is not equals to 3, second part of condition is not executed, so y is no increased ;)
27th Feb 2021, 3:08 PM
visph
visph - avatar
+ 5
++x means increment the value of x first and use it so in the first print statement x = 2 now so it would look like this 2==2&& y++ means use the current value of y first and then increment so in the print statement y = 1 and once the statment has finished y increases to 2 So y and x both equal 2 after the first print method but inside the method it would look like this (2==2&&1==1);
27th Feb 2021, 1:20 PM
D_Stark
D_Stark - avatar
+ 3
Hi! do you not understand the entire code or some part of it?
27th Feb 2021, 11:42 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
😲😲😲🙄😳
22nd Dec 2021, 4:46 PM
Angry coder
Angry coder - avatar