- JScript code
function factorial(num){ if (num < = 1){ return 1; }else{ return num * argumets.callee(num-1); } } var anotherFactorial = factorial; factorial = null; alert(anotherFactorial(4)); 为何运行时没结果
------解决方案--------------------
- JScript code
<script type="text/javascript"> function factorial(num) { if (num <= 1) { return 1; } else { return num * arguments.callee(num - 1);//这里有拼写错误arguments } } var anotherFactorial = factorial; factorial = null; alert(anotherFactorial(4)); </script>
------解决方案--------------------
- JScript code
function factorial(num){ if (num <= 1){//前面是<=,不能写成< = return 1; }else{ return num * arguments.callee(num-1);//写错了arguments,你少写了个n } }
------解决方案--------------------