Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vstarck
Created February 1, 2013 21:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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