My conclusion
I go with Arrow Function(most of the cases)
Reasons
Arrow function can be less bug-prone
- It does't allow duplicate argument names
- No hoisting with using
const
- It cannot define with the same function name with using
const
When to use Regular function
- We we want to leverage the difference of
this
behavior for regular function - In typescript, when you want to use Function Overloads (Thanks for your comments, @lexlohr ๐)
Difference in details
There are other differences between Arrow and Regular functions as well. And following reference explains very well on that with good example codes ๐
Top comments (3)
In typescript, there is another reason to go with classic functions: if you want to overload them. Otherwise, using arrow functions is a good choice.
Thanks for your comment, Alex!
Great point! Let me add this point to the article ๐
TIL: TypeScript: Documentation - More on Functions #function-overloads
Related to this topic, Kent C. Dodds introducing his loose rules. It is worth a read ๐
Function forms