getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.6k stars 1.96k forks source link

Chapter 2 - Functions Without function - arrow functions naming #176

Closed tforward closed 5 years ago

tforward commented 5 years ago

Thank for putting out more great content! I tried a few FP books and yours was the first that was actually approachable!

Chapter 2 - Functions Without function

If person.nicknames isn't defined for some reason, an exception will be thrown, meaning this (anonymous function) will be at the top of the stack trace.

Honestly, the anonymity of => arrow functions is a => dagger to the heart, for me. I cannot abide by the loss of naming. It's harder to read, harder to debug, and impossible to self-reference.

^ All good points

What about?

Const getPreferredName = person => person.nicknames[0] || person.firstName; people.map(getPreferredName);

Aside from the other underlying problems with arrow functions that you mention (no "this", different syntax ) the function name well still show up in stack trace if there is an error, but maybe I'm missing something else?

getify commented 5 years ago

That's slightly better, but only slightly, and not enough IMO to justify them.