124
Pure Evil
(lemmy.world)
Post funny things about programming here! (Or just rant about your favourite programming language.)
Automatic Semicolon Insertion (ASI) has (sadly) been a part of JavaScript longer than 2016. I'm not sure exactly when it was introduced, but this document from 2009 already contains it: https://web.archive.org/web/20120418215856/https://ecma262-5.com/ELS5_Section_7.htm#Section_7.9
IMO it's bad practice to rely on ASI since the semicolons may not get inserted where you expected them to. The following snippet
is interpreted as
which raises a
TypeError
.There are more examples of ASI not doing the right thing on the web, so I don't agree with "Javascript doesn't need semicolon".
As Mark Twain said, “Never discuss politics, semicolons, tabs, or religion in polite company.”
Use an autoformatter for all code (both in the editor on save/type and as CI check).
There is no problem anymore.