title: Javascript private member on prototype
body: <p>Well I tried to figure out is this possible in any way. Here is code:</p>
  
  <pre><code>a=function(text)
  {
     var b=text;
     if (!arguments.callee.prototype.get)
        arguments.callee.prototype.get=function()
      {
           return b;
      }
      else
        alert('already created!');
  }
  
  var c=new a("test");  // creates prototype instance of getter
  var d=new a("ojoj");  // alerts already created
  alert(c.get())        // alerts test 
  alert(d.get())        // alerts test from context of creating prototype function :(
  </code></pre>
  
  <p>As you see I tried to create prototype getter. For what? Well if you write something like this:</p>
  
  <pre><code>a=function(text)
  {
      var b=text;
      this.getText=function(){ return b}
  }
  </code></pre>
  
  <p>... everything should be fine.. but in fact every time I create object - i create getText function that uses memory. I would like to have one prototypical function lying in memory that would do the same... Any ideas?</p>
  
  <p>EDIT:</p>
  
  <p>I tried solution given by Christoph, and it seems that its only known solution for now. It  need to remember id information to retrieve value from context, but whole idea is nice for me :) Id is only one thing to remember, everything else can be stored once in memory. In fact you could store a lot of private members this way, and use anytime only one id. Actually this is satisfying me :) (unless someone got better idea).  </p>
  
  <pre><code>someFunc = function()
  {
    var store = new Array();
    var guid=0;
    var someFunc = function(text)
    {
      this.__guid=guid;
      store[guid++]=text;
    }
  
    someFunc.prototype.getValue=function()
    {
      return store[this.__guid];
    }
  
    return someFunc;
  }()
  
  a=new someFunc("test");
  b=new someFunc("test2");
  
  alert(a.getValue());
  alert(b.getValue());
  </code></pre>