function Cat(name, color)
{
    this.name = name;
    this.color = color;
}

Cat.prototype.type = "猫科动物";
Cat.prototype.eat = function(){
    console.log("吃鱼吃老鼠");
}

var c1 = new Cat("Tom", "black");
console.log(c1.type);
c1.eat();
//检测类与对象人性关系:isPrototypeOf
Cat.prototype.isPrototypeOf(c1) //true

相关文章:

  • 2021-12-21
  • 2022-02-10
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
猜你喜欢
  • 2022-12-23
  • 2021-07-08
  • 2021-10-26
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案