callee 和 caller
注意严格模式下arguments callee caller都不能用
callee
callee 指向包裹这条语句的函数本身,对立即执行函数好用,因为立即执行函数不会在全局保存函数,执行完就销毁,在内部如果想递归调用自身的话用arguments.callee
function test(a,b,c){
console.log(arguments.callee.length) //3
console.log(test.length) //3
console.log(arguments.length) //2
}
test(1,2)
caller
caller 返回一个调用包裹 caller 语句函数的函数引用
function test1(){
test2();
}
function test2(){
console.log(arguments.callee.caller); //打印test1()
}
test1();