> >(A) Where there are two or more separate statements on a single line,[color=blue][color=green]
> >you must use a semicolon to separate them.[/color][/color]
[color=blue]
> If you'd bothered to RTFM you wouldn't have written such misleading
> advice.
>
> In C-like languages *some* kinds of statement end with a semicolon
> (which in javascript can be omitted in some circumstances).
> e.g. a = 5; ++a;
> Other kinds don't end with a semicolon.
> e.g. { }
>
> The rule is different in Pascal-like languages where the semicolon is
> not part of the statement.[/color]
I think you are being unfair here. JavaScript has a semicolon insertion
mechanism which attempts to correct syntax errors by replacing linefeeds with
semicolons. I think this was a bad idea. I don't trust it. I think that relying
on it is strictly unprofessional. That said,
Semicolon insertion does not work in the middle of a line. So if you put two
statements on the same line, you must use the semicolon to separate them. That
can look Pascal-like. That said,
I think it is bad to put two statements on one line. It impairs readability and
increases the likelihood of editing mistakes.
http://www.crockford.com/javascript/lint.html