How are JavaScript objects converted to strings when using string addition?
<p>When I log something like <code>console.log('' + {});</code> the console would print <code>[Object object]</code> in Chrome, but something different (<code>{}</code>) in node. At this point I would have thought that the console output depends on the execution environment.</p>

<p>However, recently I discovered that, given some <strong>not-null</strong> object <code>foo</code>, I somehow had Chrome print <code>null</code> instead of the expected output above. So using <code>console.log('' + foo);</code> resulted in <code>null</code> in the console. How is that possible? My first guess was that I must have overridden something important accidentally, like some <code>toString()</code> method. Otherwise I could not explain why Chrome would interpret some not-null object as <code>null</code> when it is added to a string.</p>

<p>Does anyone know how that implicit object-to-string conversion actually works? It is not that this is a show-stopper, but it really makes me wonder.</p>

<p><strong>Edit:</strong> I did not include a JSFiddle because this occurs in some quite dependency-heavy class, so there is no proper minimal working example I could offer you. The question does not refer to my code anyway, it is rather basic and technical.</p>
