Re: JS - Recursion and Closures

Jonathan Logue
Wed, 28 May 2008 18:29:46 -0000

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.