#Automatic Semicolon Insertion in JavaScript—Everything You Need to Know
Friday, May 28, 2010
Automatic semicolon insertion is one of JavaScript's most controversial syntactic features. There are also many misconceptions surrounding it.
Some JavaScript programmers use semicolons at the end of every statement and some use them only where strictly required. Most do something in between and a few even intentionally add extra semicolons as a matter of style.
Even if you use semicolons at the end of every statement, some constructs parse in non-obvious ways. Regardless of your preferences in semicolon usage, you must know the rules to write JavaScript professionally. If you remember a few simple rules, all of which are explained here, you will be able to understand how any program you might encounter will be parsed and will be an expert on JavaScript automatic semicolon insertion or ASI.
##Where Semicolons are Allowed