Differences Between Named and Unnamed Anonymous Javascript Functions

Using those "named anonymous functions" won't change the behavior but will show the function name in stack traces which is very useful. Also the function gets callable within itself that way.


There are at least three advantages of using named function expressions instead of anonymous function expressions.

  • Makes debugging easier as the function name shows up in call hierarchy.
  • The function name is accessible in the inner scope of the function, so it can be used for recursion
  • The function name itself acts like a self documentation of what the function is doing instead of reading the code.