ES - Proper Tail Calls
JavaScript
function print(from, to)
{
const n = from;
if (n > to) return;
console.log(n);
//the last statement is recursive call
print(n + 1, to);
}
print(1, 10);
function print(from, to)
{
const n = from;
if (n > to) return;
console.log(n);
//the last statement is recursive call
print(n + 1, to);
}
print(1, 10);