6 ms·
I love these kind of style guides. But I also love to prove them wrong. Unless you "use strict", it's better to put var in-front of every variable if you put t
by z3t4 11y ago
I love these kind of style guides. But I also love to prove them wrong.
Unless you "use strict", it's better to put var in-front of every variable if you put them on separate lines.
var foo = 1,
bar = 2
baz = 3
vs
var foo = 1;
var bar = 2;
var baz = 3;
Forgetting a comma or semicolon in the first example might lead to silent bugs that will take hours to find.
- savanaly 11y agoIsn't this exact rule already in the guide? https://github.com/airbnb/javascript#13.2 https://github.com/airbnb/javascript#13.2
- z3t4 11y agoAhh, someone might just have added it to troll me, or I'm crazy.
- dugmartin 11y agoIf you add a lint checker, like jshint, to your build steps those kinds of bugs are found instantly. You can also add these specific style guide checks to your build steps using jscs (https://www.npmjs.com/package/jscs https://www.npmjs.com/package/jscs).