When the following code is executed in chrome console
let a, b, c;
b = 2;
a = b+1 = c = 2+3;
It says an error 'Invalid left-hand side assignment' for the last statement. But when we execute the below-given code it accepts it and does not show any error.
let a, b, c;
a = b = c = 2+3;
assignment '=' is an operator so according to operator precedence in javascript, it should work fine. what do you guys think, what is the problem?
b+1 = cto mean?ccan be equat to2+3, butb+1cannot be equal toc. In other words a variable can take on a value, but a value can't take on a variable. That would be like saying6 = 19.