using closures to create private properties referenced in prototypes
<p>I'm wondering if this is an accepted method of creating private properties to be referenced in prototypes of a new class in javascript. So instead of necessitating the creation of methods in the constructor like so:</p>

<pre><code>function Bar(){ 
  var bar = 'bar';
  this.getbar = function(){
    return bar
  }
}
</code></pre>

<p>I want to put the getbar method in a prototype like so:</p>

<pre><code>var Bar;
(function(){
  var bar = 'bar';
  Bar = function(){};
  Bar.prototype.getbar = function(){
    return bar;
  };
})();
</code></pre>
