Generally, in javascript code, semicolons may be added to the ends of lines and in many cases this eliminates the need for a line break in the code, saving one character (if that is important) or simply making the code clearer. However, there are many situations in which adding a semicolon to the end of a line of script will break the script. If you don't fully understand the code or don't know javascript fairly well and the code works 'as is', best to leave it alone.
Various situations can arise where a semicolon is not called for. One that leaps to mind is a train of variable declarations:
Code:
var p='px', a=0,
x='width', y='height', crossobj,
busy=false;
for example. Putting semicolons at the end of those lines without them will break the train.
Breaking up for in's and if, else if, else trains inappropriately with semicolons are two more. I'm sure there are others.
Bookmarks