JavaScript的caller属性(函数)
2014-09-15 22:20
218 查看
获取调用当前函数的函数。
functionName.caller备注functionName 对象是任何正在执行的函数的名称。caller 属性只有当函数正在执行时才被定义。 如果函数是从 JavaScript 程序的顶层调用的,则 caller 包含 null。如果在字符串上下文中使用 caller 属性,则其结果和 functionName.toString 相同,也就是说,将显示函数的反编译文本。下面的示例阐释了 caller 属性的用法:JavaScript
function FuncA() { if(FuncA.caller==null){ alert("called from top level"); }else{ alert("called from another function"); } } function FuncB(){ FuncA(); } FuncA();//called from top level FuncB();//called from another function
相关文章推荐
- caller 属性(函数)(JavaScript)
- JavaScript 函数的不常用属性(name/callee/caller)
- JavaScript判断变量类型:typeof函数与constructor属性异同
- 这么详细的分类 JavaScript 源代码网站你见过没有? JavaScript 中的每一个方法,每一个操作,每一个函数,每一个类.每一个属性,每一个事件都有相应的范例代码
- javascript 的函数调用过程中的arguments,callee,caller,apply,call
- Javascript 中函数的 length 属性
- JavaScript程序开发(十五)—函数的属性和方法
- javascript中用函数属性实现函数调用计数
- JavaScript中的函数:函数的apply、call方法和length属性
- javascript的函数、创建对象、封装、属性和方法、继承
- javascript的函数、创建对象、封装、属性和方法、继承
- JavaScript学习笔记(十一) 函数name属性和函数的提升
- js 获取函数的所有参数和遍历JavaScript某个对象所有的属性名称和值的方法
- JavaScript 类(函数)的Prototype属性的使用
- javascript 中的 prototype和constructor属性的使用(constructor属性始终指向创建当前对象的构造函数,每个函数都有一个默认的属性prototype,而这个prototype的constructor默认指向这个函数)
- javascript:函数的apply,call方法和length属性
- JavaScript中的私有函数;Javascript构造函数的私有方法中访问其属性和公有方法
- JavaScript中的函数:函数的apply、call方法和length属性
- [Javascript] arguments.callee.caller(如何知道到函数被谁调用了)