title: Javascript: Self and This
body: <p>Can anyone explain why do I get different values of self and this? Where self is a reference to this.</p>
  
  <pre><code>function Parent(){
     var self = this;
     this.func = function(){
        // self.a is undefined
        // this.a is 'Test'
        console.log(self.a, this.a);
     }
  }
  
  function Child(x){
     this.a = x;
  }
  
  Child.prototype.__proto__ = new Parent;
  var ch = new Child('Test');
  ch.func();
  </code></pre>
  
  <p>I've been using self on project and it's my first time to have this issue.</p>