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>
相關文章
相關標籤/搜索