码迷,mamicode.com
首页 > Web开发 > 详细

js函数的caller属性

时间:2017-11-04 13:20:29      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:函数   nbsp   this   logs   code   显示   div   caller   属性   

funcName.caller : 返回一个对函数的引用, 该函数调用了当前函数

 

function test() {
    if (test.caller) {
        var a = test.caller.toString();
            alert(a);
    } else {
        alert("this is a top function");
    }
}
function test2() {
    test();
}
test(); // this is a top function
test2(); // 显示函数 test2 的文本

 

js函数的caller属性

标签:函数   nbsp   this   logs   code   显示   div   caller   属性   

原文地址:http://www.cnblogs.com/upup2015/p/7782631.html

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