caller与callee的区别

 

callee是arguments的一个属性(arguments另一个属性是length)

 

function test(){

console.log(arguments.callee) //返回test函数引用
ƒunction test(){}

function demo(){
console.log(arguments.callee); //返回demo函数引用
ƒunction demo(){}

}

demo()

}

test()

 


caller返回一个函数被调用的环境

 

function test(){
demo();
}

function
demo(){
console.log(demo.caller); //返回demo被调用的环境
ƒunction test(){demo();}
 }

    test()

 

posted @ 2020-05-08 13:53  菜鸟程序员的总结  阅读(498)  评论(0)    收藏  举报