I'd like to extend Function.prototype with a custom method:
Function.prototype.myMethod = function() {
var fn = this;
var owner = ???;
/** ... */
};
this in that scope refers to the original function. But how do I access the this that refers to the object that "owns" the function (or whatever the outer this is at the time that fn is called)?
Function.prototype.Function.prototype.future = function() { var fn = this; var owner = ???; return fn.bind(owner, arguments); };thisvariables." Your only choice is to pass it in as a parameter.fn.bind.apply(owner)would work as you expect (ifowneris not a function). And it still does not explain what your actual goal is. I can only assume so far that extendingFunction.prototypeis not the right way.