On Jul 22, 6:29 am, Rapha <[email protected]> wrote: > Actually it can be done in Rhino now, using that 'hide' function. > > $ rhino > Rhino 1.7 release 2 2009 03 22 > js> var hide = function (o, p) { > > java.lang.Class.forName > ("org.mozilla.javascript.ScriptableObject") > > .getMethod("setAttributes", java.lang.String, > > java.lang.Integer.TYPE) > > .invoke(o, p, new java.lang.Integer( > > org.mozilla.javascript.ScriptableObject.DONTENUM)); > > } > js> Object.prototype.hello = function() { print('hello, world') } > > function () { > print("hello, world"); > > } > > js> hide(Object.prototype, 'hello') > js> var obj = {} > js> for (var p in obj) print(p) > js> obj.hello() > hello, world > js> > > However, ES5 will allow you to do it in standard javascript using the > Object.defineProperty method.
Well that's embarrassing. When I tried that it didn't work. I'll have to go back and look at my code to see what I did wrong. Thanks for taking the time to set me straight. It is working great now. _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
