If this is true, why are we using them?
I always use semicolons in JS, out of habit from Java and C#.
Yup. If you are on my team and you commit code without semicolons* I will personally light your cubicle on fire.
* You actually can’t commit code to our repo without semicolons. We run tests for standards compliance.
It comes down to a coding standard of a project you are working on. You might not be able to commit a code without semicolons into ArielLeslie’s repo, but at the same time you might also not be able to commit a code with semicolons to some other repo.
Yes, they are optional. The reason why people insert them themselves is because of automatic semicolon insertion. The gist of it being, if you want full control over where the semicolons are going to get inserted, you better write them yourself. There are a couple of caveats when not writing your semicolons, but i personally don’t have issues when omitting them.
Using or not using semicolons is more or less a matter of preference, a coding style. None is wrong, it is very useful when working in a team (even necessary) to decide on a certain style and then stick to it as a team.
Thank you for all your replies, it’s clear to me now.
I think readability is the best argument to use them anyway.
(That is, besides Ariel’s promise to light ones cubicle on fire. )