Re: JS - Recursion and Closures

Ryan Gahl
Tue, 27 May 2008 18:44:10 -0000

:)

Both are good patterns to know about (mine of course only works if you are
using prototype while yours is good old javascript).


On 5/27/08, Frederick Polgardy
<fred-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org>
wrote:
>
> 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.
> >
>


--
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
WebWidgetry.com / MashupStudio.com
Future Home of the World''s First Complete Web Platform
--
Inquire: 1-920-574-2218
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl