Accessing 'this' in Javascript closure
<p>This is more of a sanity check than anything else. I've found that when working with closures in Javascript I often use the following pattern to access the enclosing class from within the function:</p>

<pre><code>MyClass.prototype.delayed_foo = function() {
    var self = this;
    setTimeout(function() {
        self.foo(); // Be nice if I could use 'this' here
    }, 1000);
};
</code></pre>

<p>Obviously this works just fine, and it's not even a big hassle to work with. There's just this little itch in the back of my brain that says 'You're making this too complicated, dummy!' Is this the commonly accepted pattern?</p>
