Re:Say What You Mean (in JavaScript)
by chime on Tuesday May 18, 2010 @04:17PM
(#1358892)
I prefer this:
No {} necessary if it's just a single command.
[ Parent
| on HN ]
Re:Say What You Mean (in JavaScript)
by TrevorBurnham on Tuesday May 18, 2010 @04:55PM
(#1359044)
Yes, I admit that I added the curly braces unnecessarily. However, jsLint will throw a fit if you omit them, so there's an argument to be made that always putting your conditionals in curly braces is a best practice. Certainly, both styles are common in JavaScript, and they'll come out of the minifier the same way in the end.
I prefer to always use {} for readability and consistency's sake, regardless of line count. Also reduces human error.