5 ms·
> Code defensively, and don't get fancy unless you need to. You're not just complying with the language spec, you are communicating your intent to the other de
by jephir 12y ago
> Code defensively, and don't get fancy unless you need to. You're not just complying with the language spec, you are communicating your intent to the other developers who will read and maintain your code.
Leaving out semicolons actually makes the intent more clear. People run into problems with semicolon insertion when they try to create an unnamed expression, i.e:
["joe", "bob", "ann"].forEach(call);
If you use a no-semicolon style, though, you must name all your expressions, which makes your intent more clear:
var employees = ["joe", "bob", "ann"]
employees.forEach(call)
- wallyhs 12y agoWhen I mentioned intent, I was mostly referring to the use of an "if" statement vs. short circuiting in the referenced example. But I mean it in general. Every code base is different, of course. > If you use a no-semicolon style, though, you must name all your expressions. Thanks, I guess I missed that point.