zoukankan      html  css  js  c++  java
  • caller 属性(函数)(JavaScript)

    转载: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)中受支持。

  • 相关阅读:
    原生JS实现简易随机点名功能
    react 字父组件传值
    关于react组件传值问题
    轮波图
    烟花
    this的详解
    封装多元素多属性的链式缓冲
    留言板设计的流程,拖动窗口
    运动的小球
    运动的小球自动变键盘控制
  • 原文地址:https://www.cnblogs.com/johnnylion/p/3937511.html
Copyright © 2011-2022 走看看