How can I access a private variable when replacing a private function,If possible for your scenario, you could potentially use eval for
which originally had access to this variable, with another one? Or is it
just not possible?
this. For example:
Expand|Select|Wrap|Line Numbers
- function MyClass(val)
- {
- var printIt = function () { window.alert("1:" + val); }
- this.callPrintIt = function () { printIt(); }
- this.setPrintIt = function (evalStr) { eval("printIt = " +
- evalStr); }
- }
- var c = new MyClass("test");
- c.callPrintIt();
- c.setPrintIt("function () { window.alert(\"2:\" + val); }");
- c.callPrintIt();
Thanks