When returning an anonymous function from a function, is the function in the return statement a function declaration or function expression?
<p>This is the code which I got stuck on.</p>

<pre><code>var bind = function(func, thisValue) {

  return function() {

    return func.apply(thisValue, arguments);

  }

}
</code></pre>

<p>I've been learning about execution contexts and closures. My guess is that the function in the first return statement is a function expression as it's part of a statement. However, then I don't know how a closure, with reference to func and thisValue, is created.</p>

<p>If it is a function expression, then when bind is called, the anonymous function won't be evaluated there and then and therefore won't have a function object set up with a [[scope]] property containing the scope of bind's execution context. And so, the anonymous function won't have access to func and thisValue through it's [[scope]] property.</p>

<p>So if the code does indeed form a closure, then my guess is wrong and the function in the first return statement must be a function declaration. Or maybe I'm misunderstanding when return is evaluated? Any help on this would be greatly appreciated!</p>
