Javascript supports First Class Functions, in which case we can pass the function as an argument. An anonymous function that is defined inside an argument list of another functi
When you're unsure what the scopes of a function defined in the arguments list of a call is, notice that
fn(function x(…) { … })
is equivalent to
_temp = function x(…) { … };
fn(_temp)
Arguments are evaluated before the actual call, and they're evaluated in the same scope as the call itself is evaluated in.