Accessing parent function when using Function.prototype methods
<p>I'm playing around with Function.prototype as a learning exercise and was trying to make a generic curry method that could be used like this:</p>

<pre><code>// Any old function
var myFn = function(arg1, arg2) {
    console.log(arg1, arg2);
};

// Curry some parameters and return a new function
var myFnCurry = myFn.curry("A");

// Call the curried function, passing in the remaining parameters
myFnCurry("B"); // Outputs: A B
</code></pre>

<p>It's fairly straight forward to implement this feature as a function rather than a method using the following approach:</p>

<pre><code>var curry = function(fn) {
    var slice = Array.prototype.slice,
        args = slice.call(arguments, 1);
    return function() {
        fn.apply(this, args.concat(slice.call(arguments)));
    };
};

// Example
var myFnCurry = curry(myFn, "A");
myFnCurry("B"); // Outputs: A B
</code></pre>

<p>However, I really wanted to be able to utilise the Function prototype, like this:</p>

<pre><code>Function.prototype.curry = function() {
    var slice = Array.prototype.slice,
        args = slice.call(arguments);
    return function() {
        // If we call curry like this: myFn.curry()
        // how can we get a reference myFn here?
        ???.apply(this, args.concat(slice.call(arguments)));
    };
};
</code></pre>

<p>I'm not sure how to get a reference to the myFn function (denoted by the ??? above) that the curry method is being called from.</p>

<p>Is there a way to access the parent function in this circumstance?</p>

<p>Cheers,</p>

<p>Ian</p>
