you’re misunderstanding closures. a closure not only has access to its inner and outer variables, it also preserves them over the usual lifetime. (basically having acces to variables that would normally have been destroyed)
PHP Code:
Function.prototype.bind = function (obj) {
var fn = this;
return function () {
return fn.apply(obj, arguments);
}
};
without the closure, the variable
fn would be destroyed after calling (local variables exist only while the function is called). due to the closure, JS "remembers" (keeps in memory) the value of
fn (in this case a reference to a said function object)
Quote:
Originally Posted by DaveyErwin
It returns an Object , don't forget my thanks....uh
|
lol