Skip to content

Instantly share code, notes, and snippets.

@vstarck
Created February 1, 2013 21:39
Show Gist options
  • Save vstarck/4694338 to your computer and use it in GitHub Desktop.
Save vstarck/4694338 to your computer and use it in GitHub Desktop.
__noSuchProperty__
var myObject = {
__noSuchProperty__: function(name) {
return name;
}
};
var myProxyObject = new Proxy(myObject, {
get: function(target, name) {
return name in target?
target[name]:
target.__noSuchProperty__(name);
}
});
myProxyObject.foo; // "foo"
myProxyObject.foo = "bar";
myProxyObject.foo; // "bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment