JavaScript递归深度问题

递归是有限的东西:

function fact(num) {
if (num <= 1) {
return 1;
} else {
return fact(num - 1);
}
}

测试结果是35840成功,之后就失败了,递归只能这么多次了。再多就受不了了!

fact(35840)
1

fact(35841)
VM573:5 Uncaught RangeError: Maximum call stack size exceeded(…)

posted @ 2016-08-24 13:42  张朋举  阅读(1080)  评论(0编辑  收藏  举报