127
rated 0 times
[
129]
[
2]
/ answers: 1 / hits: 15613
/ 15 Years ago, sun, december 20, 2009, 12:00:00
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(/functions+([^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(/functions+([^s(]+)/) );
}
}
testobj.testfunc();
More From » function