title: javascript private member not accessible through public method
body: <p>I have following setup. method and method1 both are public methods of class Student. But why ca only "method" access private variable p</p>
  
  <pre><code>​function Student() {
      var p = 10;
      this.method = function() {
          document.write(p);
      }; 
  };
  
  Student.prototype.method1 = function() {
      document.write('here');
      document.write(p);
  };
  
  var s = new Student();
  s.method();
  s.method1();
  ​
  </code></pre>
  
  <p>How does it make sense, I mean is it "a public method that does not have access to private members!"</p>