Skip to content

Instantly share code, notes, and snippets.

@jweaver
Created August 10, 2013 23:54
Show Gist options
  • Save jweaver/6202707 to your computer and use it in GitHub Desktop.
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).
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