var foo = {};
foo.c = foo = {};
console.log(foo.c);
why the result is undefined? i thought it is supposed to be \'[object Object]\'
JavaScript engine splits such assignment:
a = b = c = 1;
As follow:
a = 1;
b = 1;
c = 1;
And not as:
c = 1;
b = c;
a = b;
There is a slightly but important difference – mostly, it involves getters, please check Multiple variable assignments in one row for further details – and that's mostly why your code doesn't behave like expected, because the initial expectations are based on false assumptions.