"Here we are using tail recursion to keep inserting the records."
Correct me if I'm wrong, but I don't think he means tail recursion. It's recursion, yes. But does tail recursion even make sense in an asynchronous setting?
He even mentions that it would blow up the stack ... so, no TCO is applied, which does not exist in javascript (at least not in V8). But tail recursive it is, as the recursion is the last statement. What he implements in the variation is a kind of pseudo-trampoline through setTimeout ...
Comments
"Here we are using tail recursion to keep inserting the records."
Correct me if I'm wrong, but I don't think he means tail recursion. It's recursion, yes. But does tail recursion even make sense in an asynchronous setting?
He even mentions that it would blow up the stack ... so, no TCO is applied, which does not exist in javascript (at least not in V8). But tail recursive it is, as the recursion is the last statement. What he implements in the variation is a kind of pseudo-trampoline through setTimeout ...