I'm trying to get the name of the currently running function. From what I've read, this should be possible using:
(arguments.callee.toString()).match(/function\s+(\[^\s\(]+)/)
However, when I run this in Firefox and Safari (latest versions on Mac) the name is not returned.
console.log( arguments.callee ) returns the source of the function, but not the assigned name. arguments.callee.name returns an empty string.
My sample code is as follows:
var testobj = {
testfunc: function(){
console.log( (arguments.callee.toString()).match(/function\s+(\[^\s\(]+)/) );
}
}
testobj.testfunc();