函数的caller属性

时间:2014-08-17 21:11:52   收藏:0   阅读:420

今天我在这里通过一个例子介绍一下函数自身的call属性。

例:

function whoCallMe(){

  alert("My caller is" + whoCallMe.caller);

};

function CallerA(){whoCallMe();};

function CallerB(){whoCallMe():};

alert{whoCallMe.caller};//输出结果为:null;

whoCallMe();//输出结果为:My caller is null;

CallerA();//输出结果为:My caller is function CallerA(){whoCallerMe();};

CallerB();//输出结果为:My caller is function CallerB(){whoCallerMe();};

虽然这个属性没怎么用,但是我觉得挺有趣的。(8/17记)

函数的caller属性,布布扣,bubuko.com

原文:http://www.cnblogs.com/chenxiaoduo/p/3918242.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!