class People {
constructor(name, sex){
this.name = name
this.sex = sex
}
run() {
console.log(`${this.name}正在跑步!`)
}
}
class Student extends People {
constructor(name,sex, order) {
super(name, sex)
this.order = order
}
study() {
console.log(`${this.name}是一名${this.sex}学生,学号是${this.order}`)
}
}
class Teacher extends People {
constructor (name, sex, major) {
super(name, sex)
this.major = major
}
teach() {
console.log(`${this.name}是一名教${this.major}专业的${this.sex}老师`)
}
}
const jack = new Student('杰克','男', '0010')
console.log(jack.name)
console.log(jack.order)
jack.study()
jack.run()
const wanglaoshi = new Teacher('王老师','男', '语文')
console.log(wanglaoshi.name)
console.log(wanglaoshi.major)
wanglaoshi.teach()
wanglaoshi.run()
console.log(Object.prototype.toString.call(Student))
console.log(jack.__proto__ === Student.prototype)
console.log('')
console