码迷,mamicode.com
首页 > 编程语言 > 详细

caller 属性(函数)(JavaScript)

时间:2014-08-26 17:06:56      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   java   使用   io   strong   

转载:http://msdn.microsoft.com/zh-cn/library/7t96kt3h(v=vs.94).aspx

 

获取调用当前函数的函数。

functionName.caller

 

备注

functionName 对象是任何正在执行的函数的名称。

caller 属性只有当函数正在执行时才被定义。 如果函数是从 JavaScript 程序的顶层调用的,则 caller 包含 null。

如果在字符串上下文中使用 caller 属性,则其结果和 functionName.toString 相同,也就是说,将显示函数的反编译文本。

下面的示例阐释了 caller 属性的用法:

 1 function CallLevel(){
 2    if (CallLevel.caller == null)
 3       return("CallLevel was called from the top level.");
 4    else
 5       return("CallLevel was called by another function.");
 6 }
 7 
 8 document.write(CallLevel());
 9 
10 // Output: CallLevel was called from the top level.

 

要求

在以下文档模式中受支持:Quirks、Internet Explorer 6 标准模式、Internet Explorer 7 标准模式、Internet Explorer 8 标准模式、Internet Explorer 9 标准模式、Internet Explorer 10 标准模式和 Internet Explorer 11 标准模式。此外,也在应用商店应用(Windows 8 和 Windows Phone 8.1)中受支持。

 

caller 属性(函数)(JavaScript)

标签:style   blog   http   color   os   java   使用   io   strong   

原文地址:http://www.cnblogs.com/johnnylion/p/3937511.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!