JS代理Proxy对象的使用

<div id="person"></div>

<script>
  const person = {
    name: "Tom",
  };

  // 设置值的时候,界面显示也随之变化
  const handler = {
    set: function (obj, prop, value) {
      obj[prop] = value;
      document.getElementById("person").innerText = value;
    },
  };

  const personProxy = new Proxy(person, handler);
</script>