title: Accessing this from within an object's inline function
body: <p>I'm having difficulty referencing "this" from within a javascript inline function, within an object method.</p>
  
  <pre><code>var testObject = {
      oThis : this,
      testVariable : "somestring",
      init : function(){
  
         console.log(this.testVariable); // outputs testVariable as expected
  
         this.testObject.submit(function(){
  
              var anotherThis = this;
              console.log(this.testVariable) // undefined
              console.log(oThis.testVariable) // undefined
              console.log(testObject.testVariable) // outputs testVariable 
              console.log(anotherThis.testVariable) // undefined
  
      }
  
  }
  </code></pre>
  
  <p>How do I access <code>this.testVariable</code> from within the submit function?
  I'm also using jQuery as well, if that makes a difference.</p>
  
  <p>I wonder if this is the best approach - and maybe I should have submit as a separate function, and then reference that inline, like:</p>
  
  <pre><code> init : function(){
  
      this.testObject.submit = this.submitForm;
  
   },
   submitForm : function(){
       // do validation here
       console.log(this.testVariable) // outputs testvariable
  
       .
       .
       .
  
       return valid; 
   }
  </code></pre>
  
  <p>But this didn't seem to work either - and I think I'd just like to keep the submit function inline within my <code>init</code> method for now.</p>