DEV Community

Discussion on: 9 Promising Promise Tips

Collapse
 
kepta profile image
Kushan Joshi • Edited

I agree that that code can be simplified into the one you mentioned, but in my humble opinion:

  • I personally find it hard to follow what is going on when you simply pass a callback reference.
  • Using this style would make it difficult for new comers to actually understand what is going on.
  • It works fine for unary callbacks like in promises, but it is a source of cryptic bugs when there is an arity mismatch between the caller and the callback.
  • It also becomes a problem when you want pass method which is context (this) sensitive. I have seen folks doing .catch(console.error.bind(console)) just to avoid that, when they could simply have used a .catch((err)=> console.error(err)).