title: Private instance variable in a modular pattern
body: <pre><code>var foo = (function(){
  
      var _blah;
  
      function doStuff(){
          //how to make _blah instance specific
          //and access it here?
      }
  
      function bar(blah){
          _blah = blah;
          doStuff();
          //this.blah = blah?
      }
  
      bar.prototype.getBlah = function(){ return _blah; };
  
      return bar;
  
  })();
  
  var foos = [];
  
  $.each([1,2,3], function(i, v){
      var f = new foo(v);
      foos.push(f);
  });
  
  //all instances of foo
  //gets _blah set to 3
  console.log(foos[1].getBlah()); 
  </code></pre>
  
  <p>I have two questions regarding the module above:</p>
  
  <ul>
  <li>How do I set a property that is specific for each instance? Right now you can see that <code>_blah</code> gets overwritten, which is pretty obvious. But I need some help with the syntax. My guess is that I need to set it in the constructor like the comment. Is that the right way to do it?</li>
  <li>How do I access the property in another method? As far as I know, <code>this</code> refers to <code>window</code> in <code>doStuff()</code>.</li>
  </ul>
  
  <p><a href="http://jsfiddle.net/ncg2M/1/" rel="nofollow">http://jsfiddle.net/ncg2M/1/</a></p>