2019-11-19 callee和caller的区别

2019-11-19  本文已影响0人  SherrinfordL

callee就是返回正在执行函数的本身引用
caller返回一个函数的引用,这个函数调用了当前的函数。

callee:

var a = function() { 
    alert(arguments.callee); 
} 
var b = function() { 
    a(); 
} 
b();

返回

alert: function() { 
    alert(arguments.callee); 
}

caller:

var a = function() { 
    alert(a.caller); 
} 
var b = function() { 
    a(); 
} 
b();

返回

![image.png](https://img.haomeiwen.com/i13747278/1be1d75c05ef9aa7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

上一篇 下一篇

猜你喜欢

热点阅读