📜  监控对对象所做的更改 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:10.533000             🧑  作者: Mango

代码示例1
var targetObj = {};
var targetProxy = new Proxy(targetObj, {
  set: function (target, key, value) {
      console.log(`${key} set to ${value}`);
      target[key] = value;
  }
});

targetProxy.hello_world = "test"; // console: 'hello_world set to test'