SOURCE

class A {
    constructor(name) {
        this.name = name
    }
}
class B extends A {
    constructor(name, age) {
        super(name) //Must call super constructor in derived class before accessing 'this' or returning from derived constructor
        this.age = age
    }
    //person类似于计算属性
    get person() {
        return this.name
    }
    //修改person的值时可以使用
    set person(name) {
        this.name = name
    }
}

let b = new B("张三",18)
console.log(b)// {"name":"张三","age":18}
console.log(b.person)// '张三'
b.person = "李四"
console.log(b.person)// '李四'
console 命令行工具 X clear

                    
>
console