Proxy 2020-3-20

# 输出是什么?

const handler = {
  set: () => console.log("Added a new property!"),
  get: () => console.log("Accessed a property!")
};

const person = new Proxy({}, handler);

person.name = "Lydia";
person.name;
  • A: Added a new property!
  • B: Accessed a property!
  • C: Added a new property! Accessed a property!
  • D: Nothing gets logged

# 参考