Auto-type conversion in JavaScript
<p>The following all expressions in JavaScript are far obvious.</p>

<pre><code>var x = 10 + 10;
</code></pre>

<p>The value of <code>x</code> is <code>20</code>.</p>

<pre><code>x = 10 + '10';
</code></pre>

<p>The value of <code>x</code> in this case is <code>1010</code> because the <code>+</code> operator is overloaded. If any of the operands is of type string, string concatenation is made and if all the operands are numbers, addition is performed.</p>

<pre><code>x = 10 - 10;
x = 10 - '10';
</code></pre>

<p>In both of these cases, the value of <code>x</code> will be <code>0</code> because the <code>-</code> operator is not overloaded in that way and all operands are converted to numbers, if they are not before the actual subtraction is performed (you may clarify, if anyway I'm wrong).</p>

<hr>

<p>What happens in the following expression.</p>

<pre><code>x = '100' - -'150';    
</code></pre>

<p>The value of <code>x</code> is <code>250</code>. Which also appears to be obvious but this expression somewhat appears to be the equivalent to the following expression.</p>

<pre><code>x = '100' +'150';
</code></pre>

<p>If it had been the case then these two strings would have been concatenated and assigned <code>100150</code> to <code>x</code>. So why is addition performed in this case?</p>

<hr>

<p><strong>EDIT :</strong></p>

<p><code>+'10' + 5</code> returns <code>15</code> and <code>'a' + + 'b'</code> returns <code>aNaN</code>. Does anyone know why?</p>
