Created
August 10, 2013 23:54
-
-
Save jweaver/6202707 to your computer and use it in GitHub Desktop.
How to use a Proxy (example). Useful for debugging, as logging can be done as the object under proxy is changed for any value(s).
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 engineer = { name: 'Joe Sixpack', salary: 50 }; | |
var interceptor = { | |
set: function (receiver, property, value) { | |
console.log(property, 'is changed to', value); | |
receiver[property] = value; | |
} | |
}; | |
engineer = Proxy(engineer, interceptor); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment