Re: JS - Recursion and Closures

Jonathan Logue
Wed, 28 May 2008 23:18:48 -0000

So, I went the route of passing in the context... after downloading
the latest prototype.js version. It is working great and now I don''t
have to pass around all those arguments. Thanks everyone!

On May 28, 11:29 am, Jonathan Logue
<jonathanlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> Wow - I left this thread thinking it was dead - boy was I wrong ;-)
> Let me digest all that. I ended up just passing in anything I needed
> from the this scope as arguments to the nested function call. I will
> play around with these other approaches when I get some time.
>
> Thanks for the great info.
>
> On May 27, 12:48 pm, "Frederick Polgardy"
<f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:
>
>
>
> > Oh yeah, I think I remember seeing that this was added.  It''s
fairly new in
> > Prototype isn''t it?
>
> > On Tue, May 27, 2008 at 2:01 PM, kangax
<kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > Moreover, #each (and most of enumerable methods) accepts
"context"
> > > object as a second argument - since this is such a common need.
>
> > > SomeComplexDataStructure.DataPart.each( function(DataPart) {
> > >  this.myRecursiveFunction(DataPart);
> > > }, this );
>
> > --
> > Science answers questions; philosophy questions answers.- Hide quoted
text -
>
> - Show quoted text -