Calling a function of a reference to a function from within a class doesn't work
<p>I've created a JavaScript class that gets a reference to a function as its constructor argument. This class has an init() function which calls the init() function of the referenced function which was passed to the constructor. However, this results in an error saying that this.aFunction.init() is undefined.</p>

<p>This is the code:</p>

<pre><code>function AClass(aFunction) {
    this.aFunction = aFunction;
}

AClass.prototype.init = function() {
    this.aFunction.init();
}

var aClass = new AClass(function() {
    return {
        init: function() {
            alert('success');
        }
    };
});

alert('Before init');            
aClass.init();
</code></pre>

<p>I've put up a jsFiddle  at: <a href="http://jsfiddle.net/sbel/8cgpH/3/" rel="nofollow">http://jsfiddle.net/sbel/8cgpH/3/</a></p>
