其他分享
首页 > 其他分享> > Proxy,getter,setter

Proxy,getter,setter

作者:互联网

let person = {
  name: 'LLC'
  , gender: 'meal'
}

let proxy = new Proxy(person, {
  get() {
    console.log('get')
    return Reflect.get(...arguments)
  }
  , set() {
    console.log('set')
    return Reflect.set(...arguments)
  }
})
console.log(proxy.name) //get
                        //LLC
proxy.name = 'LLX'  //set

标签:set,console,log,get,name,proxy,getter,Proxy,setter
来源: https://www.cnblogs.com/Lilc20201212/p/15858801.html