[Solved] Anonymous function vs Named function which is better and why [closed]


The advantages of a named function (expression) are:

  • makes it more reliable to call the function recursively, since the name becomes a binding inside the function itself.
  • can create a better call stack (by using the function name instead of <anonymous>

Using a named function (expression) might not be possible if

  • you care about IE6, which doesn’t handle them properly (it creates two functions)
  • you can’t think of a name that wouldn’t shadow a variable you need to access inside the function

solved Anonymous function vs Named function which is better and why [closed]