Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes <a href="http://es5.github.com/#x7.9" rel="nofollow">ECMA Spec</a>, which is the Javascript spec, defines the behavior like this</p> <blockquote> <p>Certain ECMAScript statements (empty statement, ... <strong>return statement</strong>, and throw statement) must be terminated with semicolons. Such semicolons may always appear explicitly in the source text. <strong>For convenience</strong>, however, such <strong>semicolons may be omitted</strong> from the source text in certain situations. These situations are described by saying that <strong>semicolons are automatically inserted</strong> into the source code token stream in those situations.</p> </blockquote> <p>Further more</p> <blockquote> <p>When a continue, break, return, or throw token is encountered and a LineTerminator is encountered before the next token, a semicolon is automatically inserted after the continue, break, return, or throw token.</p> <p>An <strong>Expression in a return</strong> or throw statement <strong>should start on the same line as the return or throw token.</strong></p> </blockquote> <p>And they have given an <strong>example</strong> of:</p> <p>The source</p> <pre><code>return a + b </code></pre> <p>is transformed by automatic semicolon insertion into the following:</p> <pre><code>return; a + b; </code></pre> <hr> <p>So your first code will be interpreted as: </p> <pre><code>return; this.firstName() + " " + this.lastName(); </code></pre> <p>with the automatically added semi colon at the end of return.</p> <hr> <p>So the spec gives practical advice to face these situations in general javascript:</p> <blockquote> <p>A postfix <strong>++</strong> or <strong>--</strong> operator should appear on the same line as its operand.</p> <p>An Expression in a <strong>return</strong> or <strong>throw</strong> statement should start on the same line as the return or throw token.</p> <p>A Identifier in a <strong>break</strong> or <strong>continue</strong> statement should be on the same line as the break or continue token.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload