title: Same variable across all Instances of a JavaScript Class
body: <p>Is there a way to create some type of variable that is the same in every instance of a JavaScript Class (no global variables)?</p>
  
  <p>For example:</p>
  
  <pre><code>function Class(){
    this.foo = 'bar';
    this.setText = setText;
    this.getText = getText;
  }
  
  function setText(value){
    this.foo = value;
  }
  
  function getText(){
    alert(this.foo);
  }
  </code></pre>
  
  <p>Now I create two instances of the same class like so:</p>
  
  <pre><code>var fruit = new Class();
  var groceries = new Class();
  </code></pre>
  
  <p>When I change the value of foo in the class fruit I also want it to be changed in groceries.</p>
  
  <pre><code>fruit.setText("apple");
  fruit.getText(); //alerts apple
  groceries.getText(); //SHOULD also alert apple
  </code></pre>
  
  <p>I am creating the instances of a class dynamically, they don't have a clear variable names (fruit, groceries) like in the example.</p>
  
  <p>Thanks!</p>