title: How to get the outer "this" reference in JavaScript
body: <p>So I have a class lets call it A. For this class I have written a few functions which I can call like this:</p>
  
  <pre><code>var a = new A();
  a.getSomething();
  a.putSomething();
  a.delSomething();
  </code></pre>
  
  <p>And so on. Now I thought I'd organize it a bit So it wouldn't get too cluttered and would look  like a bit more like this:</p>
  
  <pre><code>a.something.get();
  a.something.put();
  a.something.del();
  </code></pre>
  
  <p>And this is how I tried to achieve this:</p>
  
  <pre><code>A.prototype.something = {
    get: function(){...},
    put: function(){...},
    del: function(){...}
  };
  </code></pre>
  
  <p>But these functions (get, put and del) still need to access the common objects/functions found in A, so I need a reference to A, but I don't know how this can be achieved.</p>
  
  <p>One option I found goes like that:</p>
  
  <pre><code>A.prototype.something = function(){
    var that = this;
    return {
      get: function(){...},
      ...
    };
  }; 
  </code></pre>
  
  <p>And 'that' would be used in those (get, put and del) functions instead of 'this'. But this would mean I would have to call these functions in such way:</p>
  
  <pre><code>a.something().get();
  ...
  </code></pre>
  
  <p>Which doesn't seem very nice to me. So is there a way I could organize these things the way I originally planned?</p>