title: Why does "[] + {} === {} + []" evaluate to "true"?
body: <p>If you open your JS console and type in <code>[] + {} === {} + []</code> it tells you it's true.</p>
  
  <p>I don't understand why this is. I attempted to look up at how it's parsed.</p>
  
  <p>For <code>[] + {}</code> the <code>+</code> here is the addition operator as operands are both literals. LHS doesn't yield a number through <code>.valueOf()</code> so it performs string concatenation using <code>.toString()</code> on both operands giving us <code>""</code> + <code>"[object Object]"</code></p>
  
  <p>For <code>{} + []</code> the <code>{}</code> is an empty code block and is 'ignored', the <code>+</code> operator here is parsed as the unary plus operator, it converts its operand to a Number. Empty arrays converted to a number become <code>0</code></p>
  
  <p>So this is appears to be <code>"[object Object]" === 0</code> which surely should be false?.</p>
  
  <p>The identity operator checks if the two operands are equal without type conversion. I can't see how this ever coud be true. What part of the story am I missing?</p>
  
  <p>Edit: </p>
  
  <p>I see if you type <code>({} + [])</code> it parses it as an empty object making the RHS equal to "[object Object]". I looked this up and <code>( )</code> is the grouping operator. So perhaps this has something to do with this?</p>
  
  <p>This is not a duplicate of <a href="https://stackoverflow.com/questions/9032856/what-is-the-explanation-for-these-bizarre-javascript-behaviours-mentioned-in-the">What is the explanation for these bizarre JavaScript behaviours mentioned in the &#39;Wat&#39; talk for CodeMash 2012?</a>. Answer bullet points 1 === 2  should NOT be true.</p>