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:
Here, we’re passing a function expression that contains a free variable,
doneMessage, to the function
- 11. Anonymous Functions, Scope and Closures: Serious functions
- Publisher: O'Reilly Media, Inc.
- Released: March 2014
A good example of how parameters of the enclosing function/nesting functions can be used as parameters of the nested functions.