title: JavaScript Class Best Practice?
body: <p>I'm currently looking into different patterns for building classes in JavaScript. But no matther what pattern I see, there are still some things I am not really sure about. </p>
  
  <pre><code>var ItemManager = (function()
  {
      var p = function()
      {
          this.items= [];
      };
  
      p.prototype.addItem = function(item)
      {
          var self = this;    
          self.items.push(item);
      };
  
      return p;
  }());
  </code></pre>
  
  <p>I create the simple class <em>ItemManager</em>, this class got the function <em>addItem</em> for adding any item to the collection. Now I don't really want the variable items, which represents the collection, to be public, this variable should be private, but I don't see any possible way to use a prototyped method to access private variables.</p>
  
  <p>So what's the best practice in this case? Simply don't use private variables?</p>