[thelist] recursive JS function?

Erik Mattheis gozz at gozz.com
Mon Feb 19 23:32:08 CST 2001


At 6:10 PM -0600 2/19/01, Ben Henick wrote:
>  > Short: I have an array of deeply nested arrays. Can someone show me a
>>  JavaScript function which will access all arrays within the tree of
>>  arrays, even if I don't know how deep the tree is? Can this function
>>  start digging into the array from an arbitrary point?
>
>for (i = 0; i < Array1.length; i++)
>{
>	for (j = 0; j < Array1[i].length; j++)
>	{
>		//Whatever you want
>	}
>}
>
>Does this help?

Yes it did in the sense that I didn't step back to realize that I 
could hard code for loops as deep as the hierarchy is likely to go 
... there has to be a more eloquent way of doing it, a function that 
will call itself and operate on each array until it finds that it 
can't go any deeper ... but for now I'll have to live like an ASCII 
artist.
-- 
- Erik Mattheis
http://gozz.com/
(612) 827 3963




More information about the thelist mailing list