Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think I'm actually in total disagreement with this. I think using semicolons as statement terminators is quite easy and doesn't require any knowledge of the ASI in terms of _adding_ semicolons. The one (potential) issue with not being aware of the ASI when using semicolons as statement terminators is for something like:

  return
    {
      a: 0
    };
since you can't disable ASI. Even in the above case, however, "standard" JS style would prevent the issue.


Relying on "standard JS style" is as reliable as relying on ASI without knowing how it works.

If what you are saying is with "standard JS style" you will never add a newline after return, then I can also assume with "standard JS style" you will not:

- start a line with ++ or --

- start a line with a regex literal

- split a for statement into separate lines

So, the only issue you need to be aware of when writing semicolon-less javascript is when you start a new line with ( or [. Easy enough to remember, no?

I've personally been writing semicolon-less JS for almost two years now, and this one simple rule has been more than enough.




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

Search: