3 ms·
The purpose of the semicolon in javascript is to eliminate ambiguity. Choosing not to avail yourself is like driving without a seatbelt -- of course it's possib
by sjwright 15y ago
The purpose of the semicolon in javascript is to eliminate ambiguity. Choosing not to avail yourself is like driving without a seatbelt -- of course it's possible, but I always thought the job of a programmer was to be as unambiguous as possible.
You're not the only person reading your code. Your code isn't just being parsed by five wholly different javascript engines, it's also being parsed by the brains of every programmer who chooses to read your code.
Expecting others to learn a few stupid rules and lame syntax hacks in order to understand and match your style seems moronic. And defending the decision by noting that "the spec permits it" is doubly so.
- ern 15y agoWhen I program in C-syntax languages, I always surround loop and conditional blocks with braces, even if they have a single line of code. Even though these languages allow braces to be omitted, I consider it bad style, and error prone (although I have never seen a real bug where a programmer made an error of including multiple statements without braces). The languages do allow this style, and however distasteful I personally find it, I would expect compilers to handle it properly. I think the same should apply here, the minifier should handle the language as specified, if it can't then it is has a bug.