Created
September 24, 2012 07:49
-
-
Save stickupkid/3774826 to your computer and use it in GitHub Desktop.
Proxies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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