title: Javascript OOP - accessing the inherited property or function from a closure within a subclass
body: <p>I am using the javascript inheritance helper provided here: <a href="http://ejohn.org/blog/simple-javascript-inheritance/" rel="nofollow">http://ejohn.org/blog/simple-javascript-inheritance/</a></p>
  
  <p>I have the following code, and I have problem accessing the inherited property or function from a closure within a subclass as illustrated below. I am new to OOP javascript code and I appreciate your advice. I suppose within the closure, the context changes to JQuery (this variable) hence the problem. I appreciate your comments.</p>
  
  <p>Thanks,
  -A</p>
  
  <p>PS - Using JQuery 1.5</p>
  
  <pre><code>     var Users = Class.extend({
                  init: function(names){this.names = names;}
              });
              var HomeUsers = Users.extend({
                  work:function(){ 
  //                alert(this.names.length); // PRINTS A 
  //                var names = this.names;  // If I make a local alias it works
                      $.map([1,2,3],function(){
                          var newName = this.names.length; //error this.names is not defined.
                          alert(newName); 
                      });
  
                  }
              });
  
  var users = new HomeUsers(["A"]);
  users.work();
  </code></pre>