There is a workaround for this bug: use a function expression instead of declaration:

function outer() {

   var a = new Array();
   .
   .

   var inner = function(something) {
       a.push(something);
   }
   .
   .
   inner (whatever);
}

Mark Lundquist wrote:

Hi,

I have something like this:

function outer() {

    var a = new Array();
    .
    .

    function inner (something) {
        a.push(something);
    }
    .
    .
    inner (whatever);
}

...and the interpreter barfs with "'a' is undefined."

I tried this:

function outer() {

    var a = new Array();
    .
    .
    .
    function inner (foo, something) {
        foo.push (something);
    }
    .
    .
    inner (a, whatever);
}

...and that worked fine!

WTD, is this a scope chain bug in Rhino or something? AFAIK this is legit Javascript... am I wrong about that?

Thanks,
Mark


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to