title: Why using the unary operator + on an array gives inconsistent results in javascript?
body: <p>I was doing some testing converting values to integer in javascript and printing the output in the console when I came across with this strange behavior.</p>
  
  <pre><code>console.log(+[]) ==&gt; 0
  console.log(+[123]) ==&gt; 123
  console.log(+['123']) ==&gt; 123
  console.log(+[123, 456]) ==&gt; NaN
  console.log(+['123asdf']) ==&gt; NaN
  </code></pre>
  
  <p>I thought the values were being converted using parseInt but turns out it wasn't so I went to  the javascript conversion table <a href="http://www.w3schools.com/js/js_type_conversion.asp">http://www.w3schools.com/js/js_type_conversion.asp</a></p>
  
  <p>This give me a better idea on how conversions are performed. Acording to this table</p>
  
  <pre><code>[] =&gt; 0
  [20] =&gt; 20
  [10,20] =&gt; NaN
  ["twenty"] =&gt;NaN
  ["ten","twenty"] =&gt; NaN
  </code></pre>
  
  <p>So aparently they take the first value of the array and convert it using the specified rules. The rules of parseInt does not apply.</p>
  
  <p>I tested to reach this conclusion. You can nested it all you want, it will give you the same result.</p>
  
  <pre><code>console.log(+[[[[[[[[[[[10]]]]]]]]]]]) =&gt; 10
  </code></pre>
  
  <p>So then I thought, ok if that's the case</p>
  
  <pre><code>console.log(+[undefined]) will return NaN
  console.log(+[null]) will return 0
  console.log(+[false]) will return 0
  </code></pre>
  
  <p>those are the values expected from the javascript conversion table to integer but turns out</p>
  
  <pre><code>console.log(+[undefined]) =&gt; 0
  console.log(+[null]) =&gt; 0
  console.log(+[false]) =&gt; NaN
  </code></pre>
  
  <p>The last is the most strange because false is converted to 0, not to NaN.
  Can someone explain the strange behaviour or explain how this conversion is performed?</p>