5 ms·
Use semicolons, always. Then you don't need to learn all the rules and caveats and ambiguity.
by axod 16y ago
Use semicolons, always. Then you don't need to learn all the rules and caveats and ambiguity.
- reid 16y agoActually, if you consider the return example in the blog, you do need to learn some caveats and rules. That's the point.
- alextgordon 16y agoNo because you still have to remember that rule whether you use semicolons everywhere or not.
- axod 16y agoAnyone who would write return\n deserves all they get. It's a fun example, but it would never happen in real life.
- toolate 16y agofunction getCount() { return { 'count': 1 }; } Not what I'd do, but a common style nonetheless.
- IsaacSchlueter 16y agoIt's also completely valid JavaScript that does something very different than what it appears to. function getCount () { return undefined { // open code block 'count': /*labelled line*/ 1 //numeric expression } // close code block } // close function LINE BREAKS CONSIDERED HARMFUL.
- axod 16y agoWhich is why I'd say if you're writing javascript, use { brackets properly, and ; properly. I agree, it's a common style, but a horrible one IMHO.
- ryan-allen 16y agoJust because the rule exists doesn't mean it's the right thing to do. Adding oddities to a language that could be small and simple creates these ongoing controversies. What are PHP developers _still_ talking about? SQL injection. What are Rails developers _still_ talking about? How to use REST properly. What are JavaScript developers _still_ talking about? Semicolon's or not. This all points to poor design decisions in my mind. And we're at a loss to change the language unless we do something like CoffeeScript.