//es6
class parent{
constructor() {
this.age =18
}
}
class Childextends parent{
constructor() {
super();
this.name ='乌拉'
}
}
let ab =new Child();
console.log(ab.age,ab.name)
//es5原型链继承
function Parent(){
this.age =18
}
function Child(){
this.name ='乌拉'
}
Child.prototype =new Parent();
let ab =new Child();
console.log(ab.age,ab.name)