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

Another way we can create a closure is to pass a function to a function. The function we pass will be executed in a completely different context than the one in which it was defined. Here’s an example:

image with no caption

Here, we’re passing a function expression that contains a free variable, doneMessage, to the function


Cover of Head First JavaScript Programming


A good example of how parameters of the enclosing function/nesting functions can be used as parameters of the nested functions.