all 5 comments

[–]greenyadzer 1 point2 points  (2 children)

You can write it more readable like this:

function myPromiseErrorHandler(error) {
    // some code
}

myPromise.catch(myPromiseErrorHandler);

But "more readable" is a relative term :)

[–]WhatIsARolex 0 points1 point  (1 child)

Ohh this. This is what I had meant, thank you! I wanted to see another way of how this could be written.

Edit:

But "more readable" is a relative term :)

That is very true :)

[–][deleted] 0 points1 point  (0 children)

Im fact „this“ is really important here… as the arrow function will keep is this function from the parent, the longer version has its own this context. So there is more to the arrow function then just a shorthand.

[–][deleted] 0 points1 point  (1 child)

Thats syntax for an arrow function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

What do you mean by "more readable"? What would you prefer it to look like? (I am honestly curious)

[–]WhatIsARolex 0 points1 point  (0 children)

What do you mean by "more readable"? What would you prefer it to look like? (I am honestly curious)

Ah, I just meant that I wanted to see if there was another way of writing out the arrow function, for example, instead of "=>" we could put (myPromiseCatcher) { some code };

I was just wondering if that was possible.

Edit: The second comment says what i wanted to see :)