This question already has an answer here:
In Eloquent Javascript, Marijn Haverbeke writes:
In some cases, JavaScript allows you to omit the semicolon at the end of a statement. In other cases, it has to be there or strange things will happen. The rules for when it can be safely omitted are complex and weird. In this book, I won't leave out any semicolons, and I strongly urge you to do the same in your own programs.
What are some of the strange things that may happen when omitting the semicolon from the end of a statement?
http://lucumr.pocoo.org/2011/2/6/automatic-semicolon-insertion/