📜  代理 api javascript 获取 - Javascript 代码示例

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

代码示例1
const handler = {
  get: function(obj, prop) {
    return prop in obj ?
      obj[prop] :
      37;
  }
};

const p = new Proxy({}, handler);
p.a = 1;
p.b = undefined;

console.log(p.a, p.b);
//  1, undefined

console.log('c' in p, p.c);
//  false, 37