I am getting following error for the setter defined in the javascript: “RangeError: Maximum call stack size exceeded”.
The code4 is as follows:
setter defn :
this.__defineSetter('_myList', function(list)
{
log.debug("in setter ....");
if(this._myList == list)
{
log.debug("in setter..");
return;
}
this._myList = list;
});
call:
myMethod = function(msg)
{
try
{
this.myList = msg.myList;
}catch(e)
{
log.debug("error in calling setter... " + e);
}
}
I am unable to figure out why is it going to infinite loop??
The problem is that you call the setter from within the setter…
Should create another ‘private’ variable to store the value. Something like this…
Also use === for comparisons (always) and change __defineSetter into…