Tail recursion in JavaScript

I love JavaScript. I don’t know why but I do.

However if you want to loop over an indeterminate-size list of URLs to find out when each page last changed, it seemed hard — until I remembered tail recursion, which is pretty simple — but I don’t see many people talking about it. So I thought I’d write it up.

#### Here’s how it works

1. Arrange all the URLs in an array.

2. Write a routine that reads one URL.

3. When it completes, it recursively calls itself for the next item in the array.

4. When you fall off the array, return.


About Dave Winer

Dave Winer, 54, pioneered the development of weblogs, syndication (RSS), podcasting, outlining, and web content management software; former contributing editor at Wired Magazine, research fellow at Harvard Law School, entrepreneur, and investor in web media companies. A native New Yorker, he received a Master's in Computer Science from the University of Wisconsin, a Bachelor's in Mathematics from Tulane University and currently lives in Berkeley, California.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s