+ 1
Please help me to understand multiple assignment operators
I can't figure out how it works! can someone help me why I get an output of 11 for variable c in the code below? var a = 10; var b = 3; var c = 2; c += a -= b -= c; document.write(a); // output: 9 document.write(b); // output: 1 document.write(c); // output: 11
3 Respostas
+ 4
Read it from the right to the left:
b -= c => b -= 2 => b = 1
a -= b => a -= 1 => a = 9
c += a => c += 9 => c = 11
+ 1
Thanks! It's now make sense to me
+ 1
You're welcome 🙂