<script>
/*父类 Person*/
function Person(name,age){
this.name=name;
this.age=age;
}
Person.prototype.showName=function(){
this.name;
};
Person.prototype.showAge=function(){
return this.age;
};
function Worker(name,age,job){
Person.apply(this,arguments); /*继承属性*/
this.job=job;
}
Worker.prototype=new Person();/*继承方法*/
Worker.prototype.constructor=Worker;
Worker.prototype.showJob=function(){
return this.job;
};
//使用对象
var p1=new Person('aaa',10);
var w1=new Worker('bbb',18,'厨师');
</script>