SOURCE

const person = {};

Object.defineProperties(person, {
    name: {
        value: 'bob',
        writable: false,
    },
    age_: {
        value: 18,
        writable: true,
    },
    age: {
        get() {
            console.log('age被访问了')
            return this.age_;
        },
        set(val) {
            console.log('age被修改了')
            this.age_ =  val;
        }
    }

});
console.log(person.age)
person.age = 1;
console.log(person.age)
console 命令行工具 X clear

                    
>
console