SOURCE

let bValue
let o = {b: 29}
Object.defineProperty(o, 'b', {
    get: function() {
        console.log('监听获取b……')
        return bValue
    }, set: function(newValue) {
        console.log('监听设置b……')
        bValue = newValue
    },
    enumerable: true,
    configurable: true,
})

// o.b = 38
console.log(o.b)



console 命令行工具 X clear

                    
>
console