title: How do i make prototyped class functions without creating publicly accessible Javascript variables using this
body: <p>I write javascript all day, but I have a different style than others.  I was curious as to what are the differences in javascript in the 2 different implementations.</p>
  
  <pre><code>var ClassA = function(){
      var _value = 0;
      this.getValue = function(){ return _value; }
  }
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>var ClassB = function(){
      this._value = 0;
  }
  ClassB.prototype.getValue = function(){ return this._value; }
  </code></pre>
  
  <p>I see why based on javascript, prototypes would be used in inheritance.  I like it, but i dont like values being publicly available.    </p>
  
  <p>For example, when i instantiate <code>ClassB</code>, you can investigate and see _value inside it.  This makes it possible to be modified.</p>
  
  <p>So, how would i go about making a prototype typed function like <code>ClassB</code> but hiding the properties of the object so they cant be changed, or logged, similar to <code>ClassA</code></p>
  
  <p><strong>Edit</strong>  I did try to create <code>ClassB</code> without using <code>this</code>, but _value was not recognized in <code>getValue</code></p>