日期:2014-05-16 浏览次数:20391 次
function factorial(num){ if (num < = 1){ return 1; }else{ return num * argumets.callee(num-1); } } var anotherFactorial = factorial; factorial = null; alert(anotherFactorial(4)); 为何运行时没结果
<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>
------解决方案--------------------
function factorial(num){ if (num <= 1){//前面是<=,不能写成< = return 1; }else{ return num * arguments.callee(num-1);//写错了arguments,你少写了个n } }
------解决方案--------------------