Skip to content

Instantly share code, notes, and snippets.

@polotek
Created May 16, 2012 18:22
Show Gist options
  • Save polotek/2712799 to your computer and use it in GitHub Desktop.
Save polotek/2712799 to your computer and use it in GitHub Desktop.
// for node.js
if(typeof require == 'function') {
var load = require;
}
load('../reflect.js');
var RCVR = null;
function test() {
var target = {}
var proxy = Proxy(target, {
get: function(target, name, receiver) {
console.log('GET');
RCVR = receiver;
},
set: function(target, name, val, receiver) {
console.log('SET');
RCVR = receiver;
return true;
}
});
var child = Object.create(proxy);
child.foo;
console.log('get :' + (RCVR === child));
child.bar = 'bar';
console.log('set :' + (RCVR === child));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment