Re: JS - Recursion and Closures

Frederick Polgardy
Tue, 27 May 2008 18:41:51 -0000

Buy him a beer instead; this solution is a lot better than mine in this
case.

On Tue, May 27, 2008 at 1:04 PM, Ryan Gahl
<ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Another way to do this could be to just use proto''s .bind(),
assuming the
> "myRecursiveFunction" is only ever called as an instance method
(vs. calling
> it statically against the MyNS.Package''s prototype)...
>
> So:
>
> SomeComplexDataStructure.DataPart.each( function(DataPart) {
> *this.myRecursiveFunction(DataPart);* // or whatever the args should be
> }.bind(this) );


--
Science answers questions; philosophy questions answers.