if (a) { b(); c() }
if (a) b(), c()Or you wouldn't, of course, if it weren't for some browsers being broken and unable to handle it.
As for "they aren't going to notice that 1% file size", you could keep saying that about small optimization after small optimization until your compiler's output is 10% bigger than the competition's, at which point you will start losing significant user base.
You're making a blanket statement about Twitter developing bad code because of a recent bug. It will be fixed.
But I don't think we need to think of it in terms of Twitter's scale at all. The point is that saving 1% for basically free, is saving 1% for basically free, and that's worthwhile no matter how big you are. On its own, it's a drop in the bucket, but the cumulative effect of many small low-opportunity-cost savings is a significant low-opportunity-cost saving.
IMO, the Javascript spec is kinda dumb for being so permissive, but it is covered in the spec, so it's legit to do it either way.
Whether that's a good thing or not.
this is literally the only objective reason i have ever seen for using/not using semicolons
nnoremap A :call EndOfLine()<CR>a
fu! EndOfLine()
normal $
if getline(".")[col(".")-1] == ';'
normal h
endif
endfunctionAnyway variables in javascript have function scope, so two variables with the same name in the same function always refer to the same value, even if declared twice.
As a result I like to write all the variable statements at the top of each function, all in one var statement.
The problem then becomes that you write var a, b, c, d; and then later want to add variable e. If you aren't careful you might accidentally write var a, b, c, d; e; if you do that, the program may still work but e now has global scope. This results in nearly impossible to find bugs that may only happen if the function is recursive or it is called (perhaps indirectly) by some other function with a similarily named variable.
Considering that semicolons insertion mostly works, and the other can be a huge pain in the rear end, I can understand why people would want to skip the semicolons.
foo()
var bar = 1;
is actually run as var bar;
foo();
bar = 1; int* a, b
declares "a" as ( int* ) and b as ( int ). Instead, I just write int *a;
int *b; (function () {
'use strict';
var a = 1; b = 2;
}());
// ReferenceError: b is not defined var a,
b,
c,
d;
e;
Then your editor (which you've a integrated a linter... right?) will protested: yourJsFile.js |5 warning| 'e' was used before it was defined.
And if you have a global by the same name you'll see: yourJsFile.js |5 warning| Expected an assignment or function call and instead saw an expression.
Granted, if you assign it a default value then, yes you're going to have a bad time. But if you follow the white spacing rules of jsLint it will catch the obvious error.