What is tail recursion?
Consider a simple function that adds the first N natural numbers. (e.g. sum(5) = 0 + 1 + 2 + 3 + 4 + 5 = 15). Here is a simple JavaScript implementation that uses recursion: If you called recsum(5), this is what the JavaScript interpreter would evaluate: Note how every recursive call has to complete before … Read more