Possible duplicate:
How can I get a function name inside a JavaScript function?
The title should be clear.
Is it possible to define the name of this function from within the function?
Basically, I am adding some debugging code to many functions, and I would just like to add the following line inside each function:
if (global_debugOn) alert("Processing function " + function-name);
How can I get the 'function-name'?
Yes, obviously, I could just enter the name of the function (Iām typing the entire alert bit), but this is a hassle, especially if there is a good easy way to get it dynamically. Also, since function names change during development, I would like to keep it up to date ...
I was hoping that perhaps the arguments attribute might contain this (for example, arguments[0] , as in C), but I could not get it to work. I'm not even sure if arguments .
Thanks!
Rory
source share