callee用法
arguments的属性只有length和callee
<script>
function test(){
console.log(arguments.callee===test);//指向函数自身引用
}
test()
var num = (function (n) {
if (n == 1) {
return 1;
}
return n * arguments.callee(n - 1) //用立即执行函数实现阶乘, 要想找到它的引用,就得用arguments.callee
}(5))
</script>
<script>
function test(){
console.log(arguments.callee);//test
function demo(){
console.log(arguments.callee);//demo
}
demo()
}
test()
</script>
caller用法
<script>
function test(){
demo()
}
function demo(){
console.log(demo.caller);//调用demo的环境是test
}
test()
</script>