Skip to content

Instantly share code, notes, and snippets.

@oberhamsi
Created November 7, 2012 13:21
Show Gist options
  • Save oberhamsi/4031545 to your computer and use it in GitHub Desktop.
Save oberhamsi/4031545 to your computer and use it in GitHub Desktop.
js Proxy in rhino
var myObject = {
"foo": true,
"author": "simon",
"env": 123
}
var myProxy = new JavaAdapter(org.mozilla.javascript.NativeObject, {
// The "start" argument is here for setters and getters living
// on a prototype, so they know what to use as "this"-object.
put: function(name, start, value) {
myObject[name] = value;
},
get: function(name, start) {
return myObject[name];
}
});
print(myProxy.author)
@oberhamsi
Copy link
Author

ah, thanks! updated.

@mschwartz
Copy link

print(myProxy.xyzzy) => undefined

However, typeof myProxy.xyzzy is "string"

Seems like a bug to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment