JS arrow functions are great


JS arrow functions are great.

✅ Concise
✅ Optional implicit return
✅ Don’t have their own “this” context

But, I don’t recommended using them everywhere.

Prefer function declarations for *top-level* functions.

Here's why.

And before people reply, yes, I know some people dislike default exports.

I prefer default exports when I'm exporting one function from a file (such as a React component).

Yes, there are some default export risks related to renaming, but I rarely find that to be a pain point.

View original on X