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:
// use inside method / function
var currentMethod = arguments.callee;
Practical example:
// ONLINE-RUNNER:browser;
function a() {
var currentMethod = arguments.callee;
console.log(currentMethod.name);
}
function b() {
var currentMethod = arguments.callee;
console.log(currentMethod.name);
a();
}
b();
Output:
b
a