this.job=job;
}
//Worker.prototype=Person.prototype;//如果這樣負值原型,子類別的sayJob方法Person父類別也會有sayJob方法,因為是引用傳遞
//改成如下方式則子類別不會影響父類別:
for(var i in Person.prototype)
Worker.prototype[i]=Person.prototype[i] ;
}
Worker.prototype.sayJob=function()
alert(this.job);
}
var p=new Person('lisi','男');
//alert(p.sayJob);
var w=new Worker('zhangsan','男','打醬油的');
w.sayName();