Image by richardmasoner via FlickrHere's a good discussion of when a Javascript developer should use semicolons.
Basically, semicolons are statement separators and there are situations where a line break won't be interpreted as the end of a statement.
Many Javascript developers put them at the end of every line, but this is unnecessary. Its better to actually understand the cases where a line break won't end a statement.
If you use a minification tool that doesn't interpret line breaks correctly, bugs could be introduced. But if you use semicolons only where you need to, a bad tool will probably break most things right away. And that will be obvious. Use semicolons ALMOST everywhere and then you won't discover the problems until you test specific lines that don't have them.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment