Skip to content

Instantly share code, notes, and snippets.

@stickupkid
Created September 24, 2012 07:49
Show Gist options
  • Save stickupkid/3774826 to your computer and use it in GitHub Desktop.
Save stickupkid/3774826 to your computer and use it in GitHub Desktop.
Proxies
var p = Proxy.create({
get: function(proxy, name) { // intercepts property access
return 'Hello, '+ name;
},
set: function(proxy, name, value) { // intercepts property assignments
alert(name +'='+ value);
return true;
}
});
alert(p.world); // alerts 'Hello, world'
p.foo = 'bar'; // alerts foo=bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment