I would like to have some sort of lazy initialied object properties in javascript and would thus want to somehow overload the property read and write access i.e.:
var someval = myobj.lazyprop; // invokes myobj.get("lazyprop");
myobj.lazyprop = someval; // invokes myobj.set("lazyprop",someval);
where myobj is some object I provide to the script.
Rationale: I want to use Javascript (Rhino) as scripting engine in an application and the datastructures that need to be accessible by the scripts can be very large and complex. So I don’t want to wrap them all in advance to javascript objects, esp. since the average script in this application will only need a very small subset of them. On the other hand I want the scripts to be as simple and readable as possible, so I don’t want to require the use of get or set methods with string arguments explicitly in the scripts.
You can do it using Rhino 1.6R6 or higher with javascript getters and setters.