This is why you should always use semicolons in JavaScript. Omitting semicolons here turns this:<p><pre><code> var angry = say('Garrrr!')
// what should I say?
(amIHappy ? happy : angry)()
</code></pre>
into this:<p><pre><code> var angry = say('Garrrr!')(amIHappy ? happy : angry)()</code></pre>
Most web browsers (if you're running this code in a web browser), will do ASI (automatic semicolon insertion).<p><a href="http://jsfiddle.net/CxUXh/" rel="nofollow">http://jsfiddle.net/CxUXh/</a> works fine in Chrome, changing the console.log to an alert.<p>Not that I'm advocating omitting semicolons!