Proxy Logging Example

Log property access using a Proxy.

Preview

Code

<script>
let target = {a:1,b:2};

let proxy = new Proxy(target,{
  get(obj,prop){
    console.log("Reading:",prop);
    return obj[prop];
  }
});

console.log(proxy.a);
</script>

More JS Meta & Proxy Examples (7)