首页 > 技术文章 > caller 和 callee的对比

zhaozhipeng 2017-12-20 10:59 原文

caller是函数的一个方法,它指向调用该函数的函数

function a(){
    console.log(a.caller)  
}
function b(){
    a()
}
b()

输出:
ƒ b(){
    a()
}

callee是arguments的一个属性,他指向arguments的函数

function a(){
    console.log(arguments.callee)
}
function b(){
    a()
}
b()

输出:
ƒ a(){
    console.log(arguments.callee)
}

 

推荐阅读