How to bind this context to a self-invoking function?
<p>I am trying to get <code>this</code> from inside a self-invoking function like this</p>

<pre><code>// this is defined here and works just fine.
(function(){
    this.doSomething()
    // this is undefined here.
}/*tried .bind(this) here, but it didn't seem to help*)();
</code></pre>

<p>The actual function is a bit more complex, but here is the simplified example of the problem.</p>

<p>How do I pass <code>this</code> context to a self-invoking function like the one above besides <code>var self = this</code> outside the function then addressing it from inside as <code>self.doSomething()</code>?</p>