I am trying to decide if it worth to go with JavaScript semicolon-less style.
If I have JavaScript code without semicolon:
function(){
var first = 1
var second = 2
sum = 1 + 2
return sum
}
it will work in browser and Node.js.
But will minified (by Uglify or Closure Compiler) code work in browser and Node.js?
I’ve read the article Semicolons in JavaScript are optional. it says that it should work.
I’m personally a pro-semicolon sort of guy, but there is a compelling argument for the alternative, which is frequently not given a fair voice. As with all coding style arguments this will be a never-ending debate with no reasonable conclusion. Do what you and your team feel more comfortable with.
If you do go for a frugal semicolon approach, make sure you and your team properly understand the automatic semicolon insertion (ASI) and statement termination rules. That is definitely a good thing to understand whatever your decision.
With respect to minification: If you don’t want to risk the potential headache of a minifier bug and the associated burden of reporting it and fixing it (or waiting for a fix) because it’s not doing ASI properly, then don’t rely on ASI.