js 继承的一个例子

<script type="text/javascript">
   function Animal(){
    this.species = "动物";
    this.action = function(){alert("会跑");};
  }
  function Cat(name,color){
    this.name = name;
    this.color = color;
  }
  function Cat(name,color){
       Animal.apply(this,arguments);
    this.name = name;
    this.color = color;
  }
  var cat1 = new Cat("大毛","黄色");
  alert(cat1.action()); 
</script>

  

posted @ 2017-06-02 15:23  高敏的主页  阅读(286)  评论(0编辑  收藏  举报