Why doesn't the shorthand arithmetic operator ++ after the variable name return 2 in the following statement?
<p>I have a very simple arithmetic operator but am at my wits end why it doesn't return 2. The code below returns 1. I thought that x++ equates to x = x + 1;</p>

<p><strong>CODE</strong></p>

<pre><code>var x = 1;
document.write(x++);
</code></pre>

<p>However if I run the code as follows, it returns 2 as expected</p>

<p><strong>CODE</strong></p>

<pre><code>var x = 1;
document.write(++x);
</code></pre>

<p>What am I doing wrong?</p>
