0
点赞
收藏
分享

微信扫一扫

es6 class extends

天蓝Sea 2022-06-27 阅读 70
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()

 


举报

相关推荐

0 条评论