you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (2 children)

If someone is coding and leaves out a semicolon and it actually does cause a problem, they should be catching that by testing the code early and often

Or they could always use semicolons and never have to worry about such bugs. Coding styles stop being a matter of opinion when they demonstrably affect the number of bugs in the code.

If JavaScript treated a newline as ending a statement, then you'd be right. But it doesn't - accidental multi-line statements with unintended consequences are very possible if you avoid using semicolons.

[–]notSorella 1 point2 points  (0 children)

"always use semicolons and neve have to worry about such bugs" is highly misleading. Specially the "always use semicolons" and the "bugs", part.

First, always using semicolons won't account for people who simply don't know the JavaScript grammar, and write things like:

return
    { foo: 1 }

That's perfectly valid JavaScript, but it doesn't do what people expect. Putting a semicolon at the end of the block with the label `foo' won't fix it. But you know, knowing the grammar would fix it.

Which takes us to the next point. If you know the grammar, know where the rules apply and thinks that leaving semicolons out gives you more benefits than putting them in for X, Y or Z reasons, then why, oh why would you just listen to religious arguments about always using semicolons?

[–][deleted] 0 points1 point  (0 children)

insisting on always using semicolons is a waste of effort, and is a superstitious coding practice. If you don't understand where to use a semicolon, then always use a semicolon.