//模拟静态
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 

 

相关文章:

  • 2021-11-08
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案