EN
JavaScript - get current method reference
3 points
In this short article, we would like to show how to get currently called method reference in JavaScript.
Simple solution:
xxxxxxxxxx
1
// use inside method / function
2
var currentMethod = arguments.callee;
Practical example:
xxxxxxxxxx
1
function a() {
2
var currentMethod = arguments.callee;
3
console.log(currentMethod.name);
4
}
5
6
function b() {
7
var currentMethod = arguments.callee;
8
console.log(currentMethod.name);
9
a();
10
}
11
12
b();
Output:
xxxxxxxxxx
1
b
2
a