这种错误一般发生在递归过程中,指的超过了堆最大的存储,溢出了
function jie(n){
if(n=0){
return 1
};
return n*jie(n-1);
}
console.log(jie(6));
Uncaught RangeError RangeError: Maximum call stack size exceeded
at jie (d:\PC\vsvode\qd\test2.html:106:9)
at jie (d:\PC\vsvode\qd\test2.html:109:22)
at jie (d:\PC\vsvode\qd\test2.html:109:22)
at jie (d:\PC\vsvode\qd\test2.html:109:22)
at jie (d:\PC\vsvode\qd\test2.html:109:22)
at jie (d:\PC\vsvode\qd\test2.html:109:22)
at jie (d:\PC\vsvode\qd\test2.html:109:22)
像是这段代码,直接报错了
原因是在if条件里的n=0,无法识别,不能跳出循环了,要改成n==0就可以了