SOURCE

const person = {}
Object.defineProperties(person, {
    _name: {
        value: '李四'
    },
    age: {
        value: 20
    },
    name: {
        get() {
            return this._name
        },
        set(newVal) {
            if(newVal > 20) {
                this._name = '张三'
                this.age += newVal - 20
                return this.age
            }
        }
    }
})

const desc1 = Object.getOwnPropertyDescriptor(person,'_name')
console.log(desc1.value)
console.log(desc1.configurable)
console.log(typeof desc1.get)

const desc2 = Object.getOwnPropertyDescriptor(person,"name")
console.log(typeof desc2.value)
console.log(typeof desc2.get)
console.log(desc2.configurable)
console 命令行工具 X clear

                    
>
console