News for hackers. Stuff that matters.
Re:Say What You Mean (in JavaScript) by chime on Tuesday May 18, 2010 @04:17PM (#1358892)
I prefer this:

    if(foo()) bar();
No {} necessary if it's just a single command.
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.
Re:Say What You Mean (in JavaScript) by mshafrir on Tuesday May 18, 2010 @04:26PM (#1358920)
I prefer to always use {} for readability and consistency's sake, regardless of line count. Also reduces human error.
Re:Say What You Mean (in JavaScript) by chime on Tuesday May 18, 2010 @04:44PM (#1358990)
Me too. But if the goal was to shorten "if(foo()) { bar(); }, then I could just leave the {} braces out instead of making it "foo() && bar()".