title: How does a.x = a = {n: b} work in JavaScript?
body: <p>This is related to <a href="https://stackoverflow.com/questions/7511279/javascript-a-b-c-statements?lq=1">Javascript a=b=c statements</a>.</p>
  
  <p>I do understand that</p>
  
  <pre><code>foo = foo.x = {n: b}; // console.log(foo) =&gt; {n: b}
  </code></pre>
  
  <p>but </p>
  
  <pre><code>foo.x = foo = {n: b}; // console.log(foo) =&gt; {n: b}
  </code></pre>
  
  <p>It should equal to :</p>
  
  <pre><code>foo = {n: b};
  foo.x = foo; // console.log(foo) =&gt; {n: b, x:object}
  </code></pre>
  
  <p>Am I missing something here?</p>