title: Alternative to 'self = this' with object in javascript
body: <p>I have this code:</p>
  
  <pre><code>function Person(name){      
      var self = this;
  
      this.name = name;
  
      function hello(){
          alert("hello " + self.name);
      }
  
      return {
          hello: hello
      };
  }
  
  var newPerson = new Person("john");
  
  newPerson.hello();
  </code></pre>
  
  <p>I want to be able to use the 'this' keyword to access the 'name' property in the 'hello' function; I want an alternative to using the 'self' variable.</p>
  
  <p>Except using the $.proxy function of jquery to control the context, how can I write the same code but without the variable 'self'?</p>
  
  <p>I want a code that looks like below but 'name' is always 'undefined' when I call 'newPerson.hello()'. I don't know why because I have always believed that the scope of a function is always the object at the left of the dot of the caller and in this case, it's 'newPerson' that have been assign a value 'john' when creating the object.</p>
  
  <pre><code>function Person(name){              
      this.name = name;
  
      function hello(){
          alert("hello " + this.name);
      }
  
      return {
          hello: hello
      };
  }
  
  var newPerson = new Person("john");
  
  newPerson.hello();
  </code></pre>
  
  <p>Thank you.</p>