Skip to main content
Source Link
xdazz
  • 161.2k
  • 38
  • 255
  • 278

addNums is only available in the scope of the newly-defined function.

Quite obviously, when a function expression has a name (technically — Identifier), it is called a named function expression. What you’ve seen in the very first example — var bar = function foo(){}; — was exactly that — a named function expression with foo being a function name. An important detail to remember is that this name is only available in the scope of a newly-defined function; specs mandate that an identifier should not be available to an enclosing scope.

Read more detail form this article.