> When your code’s intention is ambiguous, your JavaScript engine will attempt to fill in the gaps.
This is kind of misleading. The JS engine isn't making some guess. There are clearly defined semantics on how ASI (automatic semi-colon insertion) operates. Let's put aside whether ASI is good or bad-it's just part of JavaScript. Ending all your lines with semi-colons won't save you, only understanding ASI will do that.
Take this example:
function foo() {
return
'A really long string that I've put on another line';
}
console.log(foo());
You'll see that `foo` returned undefined here. Why? Because ASI terminated `return\n` as a statement.Isaac Schlueter wrote a post on this years ago that pretty much says everything I'd want to say on this topic: http://blog.izs.me/post/2353458699/an-open-letter-to-javascr...