返回调用指定函数的函数.
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function test() { if (test.caller === null) console.log('test 函数在全局调用'); // 获取调用 test函数, 的函数名 console.log(test.caller.name ); // 更上面一样 console.log( arguments.callee.caller.name ); // 获取 test函数的auguments console.log( Array.prototype.slice.call(arguments)); // 获取 调用test函数,的函数的 arguments console.log( Array.prototype.slice.call(arguments.callee.caller.arguments)); } function a(arg1, arg2) { test(1) } function b() { test(2) } a(123) b() function test2 (n) { if(n <=0){ return null } // 判断 函数是否递归 console.log( test2.caller && test2.caller.name === 'test2' ? '递归' : test2.caller && test2.caller.name ); return test2(n - 1) } test2(3)
转载于:https://www.cnblogs.com/ajanuw/p/8084893.html
最后
以上就是自信裙子最近收集整理的关于js函数 test.caller 谁在调用test函数的全部内容,更多相关js函数内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复