On Jun 26, 4:53*pm, Gregor Kofler <use... (AT) gregorkofler (DOT) at> wrote:
Quote:
How can I access a private variable when replacing a private function,
which originally had access to this variable, with another one? Or is it
just not possible? |
If possible for your scenario, you could potentially use eval for
this. For example:
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