es6 class extends

class Person{
            constructor(name) {
                this.name=name
            }
            say(){
                console.log('hi:'+this.name)
            }
        }
        const p=new Person("howhy")
        class Student extends Person{
            constructor(name,grade) {
                super(name)
                this.grade=grade
            }
            study(){
                console.log(this.name+" is on "+this.grade)
            }
        }
        p.say();
        const st=new Student("s1","33")
        st.study()

 

posted @ 2021-07-26 11:32  howhy  阅读(21)  评论(0)    收藏  举报