DEV Community

Discussion on: Semi colons;

Collapse
 
vitalcog profile image
Chad Windham

#ShamelessPlug

When I read current ECMAScript specs (1.5ish years ago) it clearly states semicolons are optional... That is because of automatic insertion when it is parsed out. People will point to very contrived situations where not having a semicolon causes an error, but they are few and far between. Also, there are lots of situations where using a semicolon doesn't do what you think it will and there is still a parsing error (also usually very contrived examples...). In the situations where it will throw an error just understand the rules and put in a semicolon, not hard once you understand. But the idea the "just using semicolons at the end of every statement" just magically makes everything "safer" is more rooted from years ago when some parsers didn't honor the language specs properly, but they do now. There is a reason semicolon free JS is becoming more and more prevalent.

Because it is fine and within the specs of the language.

But if code sacrificed to semicolons causes your brother to stumble, do the loving thing and throw in some semicolons...