title: Why do results vary based on curly brace placement?
body: <p>Why do the code snippets below, taken from <a href="http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/" rel="noreferrer">this article</a>, produce different results due to only a single change in the placement of curly braces?</p>
  
  <p>When the opening curly brace <code>{</code> is on a new line, <code>test()</code> returns <code>undefined</code>, and "no - it broke: undefined" is displayed in the alert.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function test()
  {
    return
    { /* &lt;--- curly brace on new line */
      javascript: "fantastic"
    };
  }
  
  var r = test();
  try {
    alert(r.javascript); // does this work...?
  } catch (e) {
    alert('no - it broke: ' + typeof r);
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>When the brace is on the same line as <code>return</code>, <code>test()</code> returns an object, and "fantastic" is alerted.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function test()
  {
    return { /* &lt;---- curly brace on same line */
      javascript: "fantastic"
    };
  }
  
  var r = test();
  try {
    alert(r.javascript); // does this work...?
  } catch (e) {
    alert('no - it broke: ' + typeof r);
  }</code></pre>
  </div>
  </div>
  </p>