title: Am I using Javascript call-backs appropriately (object-oriented style)?
body: <p>I have the following code example to use an object that receives the action from the callback.  Doesn't seem like this is a good design pattern.  Or is it?  </p>
  
  <p>When <code>setTimeOut()</code> fires on the function after 1 second, it uses the <code>objInstance</code> global variable (DOM scope) to access the ClassExample object instance.  Can someone recommend a better way to utilize callbacks within an object oriented design?  </p>
  
  <p>The whole idea is so I can use the callback to update data within my object instance (increment a variable for example).  </p>
  
  <pre><code>function ClassExample{
      this.initiate = function() {
          setTimeOut(objInstance.afterTimeOut,1000); //using the objects global handle
      }
  
      this.afterTimeOut = function() {
          alert("Received!");
      }
  
  }
  
  var objInstance = new ClassExample(); //instance
  objInstance.initiate();
  </code></pre>