caller,英文:来访者。 简单的说就是谁打电话给我,谁在调用我。
callee,英文:被访者。简单的说就是接电话的人,就是正在执行的函数。
caller 返回一个函数的引用,该函数调用了当前的函数,如果没有则返回null。
callee 返回当前函数的引用
function foo(){
bar();
console.log("Print Foo's callee ==>");
console.log(arguments.callee);
}
function bar(){
console.log("Print Bar's caller ==>");
console.log(bar.caller);
}
foo();
在执行foo函数时
对于bar函数来说caller就是foo函数,callee就是bar函数
对于foo函数来说caller就是null,callee就是foo函数
如下所示
document.write(payload);
对于writer来说,callee的名字就是write,caller的名字就是document
window.location.hash.substr(1)
对于hash来说,callee的名字就是hash,caller的名字就是window.location