码迷,mamicode.com
首页 > Web开发 > 详细

js 继承的一个例子

时间:2017-06-02 17:49:59      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:javascrip   action   text   var   arguments   color   this   继承   div   

<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>

  

js 继承的一个例子

标签:javascrip   action   text   var   arguments   color   this   继承   div   

原文地址:http://www.cnblogs.com/gaomin-s/p/6933533.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!