JavaScript Concern from a recent review
Myk Melez
myk at mozilla.org
Mon Apr 9 14:40:07 UTC 2007
Colin Ogilvie wrote:
> I'm concerned by a recent review Myk did on a JavaScript file (quoted
> above) where he says that for one-line conditionals and loop blocks
> you should omit braces (as a Nit).
>
> I'd like to suggest that this is a bad practice, and possibly going to
> cause confusion in the future, particularly in the example above. For
> clarity, it would be better written including braces.
The advantages to omitting braces are code concision and consistency
with Firefox coding practices.
> Does anyone else have thoughts on this, or is it just because I've
> been bitten by this in something I was doing at work...
I've been bitten occasionally by implicit braces, but I'm bitten
regularly by complex code, and braces for one-line blocks adds to that
complexity without providing enough compensatory elucidation, IMHO.
-myk
More information about the developers
mailing list