To get a function's name inside a function I can use this code:
function getmyname() {
var myName = arguments.callee.toString();
myName = myName.substr('function '.length);
myName = myName.substr(0, myName.indexOf('('));
alert(myName); // getmyname
}
however I need to run this a lot of times, so I'd rather use a function that does it, so it would look like:
function getmyname() {
alert(getfname()); // getmyname
}
so getfname()
would get the name. How can this be done?