title: How to declare a static variable in Javascript
body: <p>In the following code, I would like to have a counter to keep track of the number of Person objects created. This code is not doing so, how would I accomplish that?</p>
  
  <pre><code>function Person(){
      this.name = "Peter";
      this.counter = this.counter + 1;
      alert(this.counter);
  }
  
  Person.prototype.counter = 0;
  
  var p1 = new Person;
  var p2 = new Person;
  </code></pre>