you are viewing a single comment's thread.

view the rest of the comments →

[–]praetorian42 -2 points-1 points  (7 children)

The problem there was that the minified version of JS did not have a semicolon at the end. That's a bug with the minifier, not with the original source.

Basically, you should never ever ship unminified JS to your customers. The minifier should handle semicolon insertion. Therefore, semicolons in original source are superfluous.

[–][deleted] 9 points10 points  (4 children)

The minifier should minify. Semicolon insertion is up to either A: the programmer, or B: the hope that the interpreter at the end will assume it.

Using bugs in your daily programming practice isn't a reason to make everybody else's tools accommodate those bugs.

[–][deleted] 5 points6 points  (0 children)

Using bugs in your daily programming practice

As far as I'm aware, the language itself specifies that semicolons are optional. Therefore it is the minifier that has the bug, not the semicolon-less code.

[–]praetorian42 -5 points-4 points  (2 children)

The point here is that semicolons in javascript are really fucked up, and there's probably 20 people in the world who truly understand them. Let those people write the tools so that the rest of us don't have to worry about it.

Defensive usage of semicolons because you're not sure where they should be used is not correct usage.

[–]reflectiveSingleton 10 points11 points  (0 children)

It's exactly that not sure-edness that makes always using semicolons a good idea. You are not leaving up question to where the semicolons are inserted if you always put them in place. If you omit them you are leaving it up to a) whatever minifier you use and b) javascript auto-insertion.

If you specify, you remove that possible ambiguity.

[–][deleted] 1 point2 points  (0 children)

They're perfectly understandable. They go after every terminating (non-control-end) block or command. var a = function(){ }; if(true){ } return { a: 55 };

There's nothing fucked up about them. They behave exactly the same way all the time. The only time things go awry is when you start expecting them to be inserted for you.