When does the js engine insert semicolons?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion">What are the rules for Javascript&#39;s automatic semicolon insertion?</a>  </p>
</blockquote>



<p>I know you can chain js (or jquery) on differnt lines like so:</p>

<pre><code>$('div')
    .filter(':first').hide().end()
    .find('span').css('opacity', .5)
    ...;
</code></pre>

<p>And the engine doesn't put semicolons in which would break it. On the other hand if I do this:</p>

<pre><code>return
    i ? 1 : 2
</code></pre>

<p>It puts a semicolon in and always return undefined. What are the guidelines for when it does what?</p>
