javaScript 面向对象 触发夫级构造函数

class Person{
    constructor(name,age){  //直接写属性
        this.name=name;
        this.age=age;
        console.log('a');
    }
    showName(){  //直接可以写方法
        return this.name
    }
    showAge(){
        return this.age
    }

}
class Student extends Person{ 
    
    showJob(){
        // return this.job
    }
}

var xiaohua=new Student();//a
var xiaolv=new Student();//a

 

posted @ 2019-05-03 10:38  liliyou  阅读(262)  评论(0编辑  收藏  举报