+ 5
What is the order for multiple assignment operators on one line?
Sorry if the question was already asked, I didn't find an answer... I was wondering what how variables are exactly assigned when there are multiple assignement operators on one line. For example: var x=0; var y=6; x += y /= 3; So is it assigned like x = x+y and then y = y/3? That means x=6 and y=2. or is it first y = y/3 (also 2) and then x=x+y where x=2 (not 6). I hope my question is clear... I post it for Javascript, but I guess the rule will be the same for other languages like Java (?) Thank you very much for your help!!! Sololearn rocks! 🤘
3 Respostas
+ 4
Nope, both x and y equals 2 (tested)
I think js performed right side thing before assigning x.
y /= 3 // 6/3 = 2
x += y // 0+2 = 2
Hope you got it
+ 4
Thanks! Got it! 👍
+ 3
Find out by testing.
https://code.sololearn.com/WrSEW8xi5NNF/?ref=app