O'Reilly logo
  • Ahmed Elgendy thinks this is interesting:

Notice that the rules for when you can refer to a function are the same within a function as they are at the top level. That is, within a function, if you define a nested function with a declaration, that nested function is defined everywhere within the body of the function. On the other hand, if you create a nested function using a function expression, then that nested function is defined only after the function expression is evaluated.


Cover of Head First JavaScript Programming


How are nested functions executed?