title: Javascript increment while assigning
body: <p>I was having a conversation about the prefix increment operator, and we seem to have run into a disagreement.</p>
  
  <p>When running this code:</p>
  
  <pre><code>var x = 0;
  x = ++x;
  </code></pre>
  
  <p>is the second line equivalent to:</p>
  
  <ul>
  <li>x = (x = x + 1) OR</li>
  <li>x = (x + 1)</li>
  </ul>
  
  <p>It is hard to tell the difference because the results are identical (both result in <code>x</code> having a value of 1)</p>
  
  <p>I believe that the value is not saved to the original variable when the left hand side of the assignment is the variable itself. </p>
  
  <p>My counterpart disagrees and thinks the value is saved to the original variable whenever the <code>++</code> operator is used.</p>
  
  <p>Which one of us is right?</p>