function factorialNormal(n) {
if (n === 1) {
return n
}
return n + factorialNormal(n - 1)
}
function factorialWithTail(n, acc) {
if (n === 1) return acc;
return factorialWithTail(n-1, n + acc)
}
recursion function is fast than tail-recursion and the tail use more memory, causing the maximum call stack
Detailed answer here: ES6 Tail Recursion Optimisation Stack Overflow
There is no TCO on V8 currently.