Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes a semi-colon matter in JavaScript
    text
    copied!<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="https://stackoverflow.com/questions/4002234/do-we-need-semicolon-at-the-end">do we need semicolon at the end</a><br> <a href="https://stackoverflow.com/questions/2399935/why-use-semicolon">Why use semicolon?</a><br> <a href="https://stackoverflow.com/questions/42247/are-semicolons-needed-after-an-object-literal-assignment-in-javascript">Are semicolons needed after an object literal assignment in JavaScript?</a><br> <a href="https://stackoverflow.com/questions/537632/should-i-use-semi-colons-in-javascript">Should I use semicolons in JavaScript?</a><br> <a href="https://stackoverflow.com/questions/2983753/should-i-use-semicolon-at-end-of-line-when-coding-javascript">should I use semicolon at end of line when coding JavaScript?</a><br> <a href="https://stackoverflow.com/questions/1976445/enforce-semicolons-in-my-javascript">Enforce semicolons in my Javascript?</a><br> <a href="https://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion">What are the rules for JavaScript&#39;s automatic semicolon insertion (ASI)?</a><br> <a href="https://stackoverflow.com/questions/4054204/ive-heard-javascript-inserts-automatically-and-that-may-cause-problems">I&#39;ve heard Javascript inserts &quot;;&quot; automatically and that may cause problems</a><br> <a href="https://stackoverflow.com/questions/444080/do-you-recommend-using-semicolons-after-every-statement-in-javascript">Do you recommend using semicolons after every statement in JavaScript?</a><br> <a href="https://stackoverflow.com/questions/1834642/best-practice-for-semicolon-after-every-function-in-javascript">Why should I use a semicolon after every function in javascript?</a><br> <a href="https://stackoverflow.com/questions/5171651/javascript-why-is-a-semicolon-required-at-end-of-line">Why is a semicolon required at end of line?</a> </p> </blockquote> <p>This was a strange issue I faced once I was coding.</p> <p>Consider the following:</p> <pre><code>function foo() { alert("This does not have a semi-colon and works in Chrome but not in IE") } </code></pre> <p>and </p> <pre><code>function foo1() { alert("This has a semi-colon and works everywhere"); } </code></pre> <p>Why does this happen?</p>
 

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