title: javascript how to get this.variable in callback function
body: <p>In the following customized class in javascript, in callback, why does this.obj have nothing but local variable obj has thing I want?  Thanks.</p>
  
  <pre><code>function ClassTest(director) {
    this.obj = {"test1": "test1"};
  }
  
  function test1(input, callback) {
    callback("success");
  }
  
  ClassTest.prototype.test = function() {
    var obj = this.obj;
    test1("niuniu",function(e){
      console.log(this.obj);  // undefined
      console.log(obj);  // this one has stuff
      });
  }
  
  // run 
  new ClassTest().test()
  </code></pre>