源代码:
<html> <script> var handler = { get: function(target, name) { debugger; console.log("proxy handler called, context: " + target + " proxy name: " + name); for( var pr in target){ console.log("property: " + pr + " native? " + target.hasOwnProperty(pr)); } return name in target ? target[name]: 37; } }; var p = new Proxy({ac: "Jerry"}, handler); p.a = 1; p.b = undefined; console.log(p.a, p.b); // 1, undefined console.log('c' in p, p.c); // false, 37