3 ms·
Most of those examples are designed to push the edge cases in confusing ways (i.e. bad code). Easy answer: don’t do that. Even if you include semicolons in all
by jacobolus 16y ago
Most of those examples are designed to push the edge cases in confusing ways (i.e. bad code). Easy answer: don’t do that.
Even if you include semicolons in all the “reasonable” places for them, it’s quite possible to get tripped up if you don’t understand what counts as a statement in JS and what doesn’t.
Edit to add: For example, don’t write code like this, with or without the autoinserted semicolons:
var x = function()
{
return (function(n){
return n
})(n)
}(function(){Math.exp(
f
)})
Someone else looking at the code is hardly going to be better off understanding it if you change that to:
var x = function()
{
return (function(n){
return n;
})(n);
}(function(){Math.exp(
f
);});