Hacker News new | past | comments | ask | show | jobs | submit login

I think this style ("npm style") is trying too hard to be clever without much benefit. Classic JavaScript style (see: Crockford) has done just fine and is familiar to everyone who knows C-style syntax. No reason to change it now.

I'd rather consistently have semicolons at the ends of lines than crap like this:

    ;(x || y).doSomething()
    ;[a, b, c].forEach(doSomething)
It's easier to always include the semicolons at the end of statements rather than try to figure out the edge cases where missing a semicolon would change the behavior.

I'm also not a fan of the "comma-first" style, especially for var declarations...

    var foo
      , bar
      , baz
      ;
I prefer:

    var foo;
    var bar;
    var baz;
It's fewer lines, consistent, symmetrical, and it's impossible to introduce errors through copy/paste or reordering.



I've grown to prefer:

    var foo,
        bar,
        baz;
It seems less cluttered. You can of course introduce errors through copy/paste/reordering, but I think it's a reasonable tradeoff. I agree about comma/semicolon-first being strange though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: