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)).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice. I may be in the 0.01% that needs to use
.then(x, y)
so thanks for explaining the differenceAlso in your first example, I'm pretty sure
...can be simplified to
... because of function currying, assuming
ServerStatusPromise
accepts one value and returns one value.This means you can do things like:
I agree that that code can be simplified into the one you mentioned, but in my humble opinion:
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))
.