You can also make your counter variable "private", declaring it as local to a closure.
It's the best way to have something similar to private - static variables:
var Person = (function() {
var counter = 0;
return function() {
counter++;
this.name = "Peter";
alert(counter);
};
})();
var p1 = new Person();
var p2 = new Person();
Example: https://jsfiddle.net/patodiblasi/67wucsqx/