JavaScript array to number
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7202157/can-you-explain-why-10">Can you explain why ++[[]][+[]]+[+[]] = 10</a>  </p>
</blockquote>



<p>I'm wondering something for few days...I know that unary plus in JavaScript first converts it's operand to Number. I'm applying + to an empty array and I get the following result:</p>

<pre><code>+[] == 0
</code></pre>

<p>When I do this:</p>

<pre><code>+[1] == 1
</code></pre>

<p>But:</p>

<pre><code>+[1,2] == NaN
</code></pre>

<p>The last two things are almost clear but why the empty array is 0?!
Is this connected with:</p>

<pre><code>[] == false
</code></pre>

<p>Some times ECMAScript makes me wonder a lot...</p>

<pre><code>alert([![]+[]][+[]][+[]]+[![]+[]][+[]][+!+[]]+[!+[]+[]][+![]][+![]]+[![]+[]][+[]][+!+[]]+[![]+[]][+[]][+!+[]+!+[]]+' '+(![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]);
</code></pre>

<p>Best regards!</p>
