A JavaScript language problem
<p>In the following example</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;script&gt;
    var str = '11';
    str = str++;
    alert(str); // 11
&lt;/script&gt;
</code></pre>

<p>why is the result <code>11</code> and not <code>12</code>?</p>

<p>In this example the result is <code>12</code>:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;script&gt;
    var str = '11';
    str++;
    alert(str); // 12
&lt;/script&gt;
</code></pre>

<p>Why is this so?</p>

<p>Thank you!</p>

<hr>

<pre><code>var str = 10;
var re = str++;
alert(re); // 10
alert(str); // 11
</code></pre>

<p><code>str</code> will return 10 to <code>re</code> first, and then increments <code>str</code> itself to 11.</p>

<p>But</p>

<pre><code>var str = 10;
var str = str++;
alert(str); // 10
</code></pre>

<p>In this case, <code>str</code> return 10 to <code>str</code> first, and then <code>str</code> should increments <code>str</code> itself to 11.</p>

<p>But it doesn't. Can anyone explain this?</p>

<p>Thank you!</p>
