知識社群登入
繼承 (Inheritance)
by 蘇德宙, 2011-02-05 16:18, 人氣(1510)
 
var animal = function() {
  this.eat = function()  { alert("animal eat"); }
  this.walk = function() { alert("animal walk"); }
}
 
var dog = function() {
  this.play = function() { alert("dog play"); }
  this.walk = function() { alert("dog walk"); }
}
 
dog.prototype = new animal;
 
var bill = new dog();
bill.play();
bill.eat();
bill.walk();