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

The bit on the comma operator may be used in many other places, and I've seen it result in quite elegant code, particularly in small function bodies. Its use in the ternary here may be questionable, but in any case a good JS dev should know when it is appropriate.

My only gripe is with placement of commas in object literals and variable declarations which has become so common over the past three or four years.

  var x = 1
  ,   y = 2;
or

  var x = 1
     ,y = 2
or

  {
       k: 1
      ,k2: 2
  }
Are terribly unsightly, and do not in any way benefit the maintainer. It's just now you have to worry about the first line rather than the last one.


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: