by davidsiems · 15y ago · 0 comments
"One of the mistakes in the language is semicolon insertion. This is a technique for making semicolons optional as statement terminators. It is reasonable for IDEs and shell programs to do semicolon insertion. It is not reasonable for the language definition to require compilers to do it. Use semicolons."
http://javascript.crockford.com/survey.html
I'm inclined to agree. You already have to deal with enough complexity while you're programming, why add more? It's easier to follow the rule 'always use semicolons' than to try to selectively use them.
Because JavaScript allows semicolon insertion some syntax is parsed in a way which is surprising to those skilled with other curly brace languages. This can causes problems if you do or don't try to leave out semicolons.
The solution to avoiding unexpected behavior is to run JSLint. JSLint will insist that you use semicolons. So you will have to use semicolons.