// console.log('hello')
// function Father () {
// this.name = '父亲'
// this.age = '66'
// this.say = function () {
// console.log(" I'm father")
// }
// }
// const abb = new Father()
// console.log(abb.name) // 父亲
// ES6 新写法
class Father {
constructor () {
this.name = '父亲'
this.age = '66'
}
say () {
console.log(" I'm father")
}
}
const add2 = new Father()
console.log(add2.name) // 父亲
add2.say() // I'm father
// 继承
class Teacher extends Father {
// 复杂的写法
// constructor () {
// // constructor 里面调用 this 之前, 一定要写super()
// super()
// this.name = '老师'
// }
// 简单写法
name = '老师'
song () {
console.log('song')
}
}
const add3 = new Teacher()
console.log(add3.name) // 老师
add3.song() // song