callee关键字使用可降低代码耦合度
<script type="text/javascript">
//callee关键字使用
/*
求n的阶层的函数
n! = n*(n-1)!
5! = 5*4*3*2*1
4! = 4*3*2*1
3! = 3*2*1
2! = 2*1
1! = 1
*/
function jiecheng(n){
if(n==1){
return 1;
} else {
//return n*jc(n-1);
return n*arguments.callee(n-1);
}
}
console.log(jiecheng(5));//120
console.log(jiecheng(6));//720
var jc = jiecheng; //把jiecheng的引用传递给变量jc一份,使得jc也可以当做函数调用
jiecheng = null; //把jiecheng给销毁,避免后边代码使用
console.log(jc(4));
</script>

浙公网安备 33010602011771号