Languages
[Edit]
EN

JavaScript - get current method reference / currently called method

3 points
Created by:
Marcin
16360

In this short article we would like to show how to get currently called method referencje 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();

 

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - friendly IT community for everyone.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join