function Person(name,age){
this.name = name;
this.age = age;
}
Person.prototype.showName = function(){
console.log(this.name)
}
Person.prototype.showAge = function(){
console.log(this.age)
}
console.log('p',Person)
const p =new Person('wang',18);
const Worker = function(name,age,job){
Person.call(this,name,age)
this.job = job;
}
Worker.prototype = new Person();
Worker.prototype.constructor = Worker;
Worker.prototype.showJob = function(){
console.log(this.job)
}
console.log('w',Worker)
console.log('p2',Person)
const w = new Worker('li',20,'teacher');
class Person2{
constructor(name,age){
this.name = name ;
this.age =age;
}
showName(){
console.log(this.name)
}
showAge(){
console.log(this.age)
}
}
console.log('cp',Person2)
const p2 = new Person2('zhao',30);
class Worker2 extends Person2{
constructor(name,age,job){
super(name,age);
this.job = job
}
showJob(){
console.log('job')
}
}
console.log('cw',Worker2);
console.log('cp2',Person2);
const w2 = new Worker2('sun',88,'doctor');
.box{
width:100px;
height:100px;
background:red;
margin:10px;
float:left;
}
console