Why use semicolon? [duplicate]

Solution 1:

Because JavaScript does nasty things to you when it guesses where to put semicolons. It's better to be explicit and let the interpreter know exactly what you meant than it is to let the idiot box guess on your behalf.

References:

  • http://www.webmasterworld.com/forum91/521.htm
  • http://www.howtocreate.co.uk/tutorials/javascript/semicolons
  • http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/

...and a cast of thousands.

Solution 2:

It looks like there are very few reasons, or, actually, edge cases, when one would want to use semicolons.

http://aresemicolonsnecessaryinjavascript.com/ <- this is down now, use

https://github.com/aresemicolonsnecessaryinjavascript/aresemicolonsnecessaryinjavascript.github.com