title: JavaScript: that vs this
body: <p>I am trying to understand better the use of that and this in JavaScript. I am following Douglas Crockford's tutorial here: <a href="http://javascript.crockford.com/private.html" rel="nofollow">http://javascript.crockford.com/private.html</a>
  but I am confused regarding a couple of things. I have given an example below, and I would like to know if I am making a correct use of them:</p>
  
  <pre><code>function ObjectC()
  {
     //...
  }
  
  function ObjectA(givenB)
  {
     ObjectC.call(this); //is the use of this correct here or do we need that?
  
     var aa = givenB;
     var that = this;
  
     function myA ()
     {
        that.getA(); //is the use of that correct or do we need this?
     }
  
     this.getA = function() //is the use of this correct?
     {
         console.log("ObjectA");
     };
  
  
  }
  
   function ObjectB()
   {
  
      var that = this;
  
      var bb = new ObjectA(that); //is the use of that correct or do we need this?
  
      this.getB = function()
      {
          return bb;
      };
  
      that.getB(); //is the use of that correct or do we need this?
  
  
   }
  </code></pre>
  
  <p>Note this is just an example.</p>