Does the anonymous function in Foo get re-created in memory each time Foo() gets called?
function Foo(product)
{
return function(n) {
return n * product;
}
}
I'm more or less interested in V8's implementation in particular, since I'm not seeing anything in regards to that in the spec (unless I'm missing something, which I probably am).
I'm kind of confused on the memory management going on since the use of product is specific to the closure that is returned; however, that doesn't necessarily say the inner function has to be re-created along with a closure instance (in theory), since you can still .bind() without losing closure values.
.bind()have to do with not losing the closure values. I'm not understanding your point there.Foo(n).bind()wouldn't changenin the function returned by the call tobind.