I mean, you have to no matter what. Even if you use semicolons, it'll still insert them for you automatically if you forget any. That's kinda annoying, since it means that there's certain ways to write code that will never work as you might expect whether you use semicolons or not.
Eg,
function weirdAdd(x, y)
{
return
x + y;
}
weirdAdd(1, 2);
In languages without automatic semi-colon insertion, such a thing would work as expected, but in JS, it's return; x + y;. And while this example is trivial to detect, not all are.
All joking aside, I felt that strict mode should have disable ASI. Heck, strict mode really did not do enough in my book. I would have liked it to disable implicit type coercion, too (so that "1" + 2 would be an error instead of "12").
View all comments
Show parent comment
8
u/miauw62 Sep 08 '17
Yeah man let me just rely on the infamously stable and coherent language of Javascript to put semicolons where they should be.