window.onload=function(){
new Preson('liujian','男').show();
new Work('liujian','男','工人').show();
new Work('liujian','男','工人').ShowWork();
}
function Preson(name,sex){
this.name=name;
this.sex=sex;
}
Preson.prototype={
show:function(){
console.log(
this.name
)
},
Sex:function(){
console.log(
this.sex
)
}
}
function Work(name,sex,work){
Preson.call(this,name,sex,work);
this.work=work;
}
/*
for (var i in Preson.prototype) {
Work.prototype[i]=Preson.prototype[i]
}
*/
Work.prototype=Object.create(Preson.prototype);
Work.prototype.constructor=Work;
Work.prototype={
show:function(){
alert(1)
},
ShowWork:function(){
console.log(this.work+','+this.name)
}
}