//模拟静态 var Animal = function(name){ this.name = name; Animal.instanceCounter ++; }; Animal.instanceCounter = 0; Animal.prototype.sayHellow = function(){ console.log('this.name'); } var animal = new Animal('name'); var animal2 = new Animal('name2'); console.log(Animal.instanceCounter);//2 console.log(animal.instanceCounter);//undefined