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

>This line "(a.c || [])()" is bothering me -- why on earth would this line exist in any program?

A variation of it is valid for method selection, such as:

  (cond ? a.foo : b.bar)();
or, for method fallback:

  (a.foo || a.fooDefault)();
Neither does work in js, though.


This is useful and works with functions that don't use `this` (like arrow functions).




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

Search: