How can I get the function name inside a function in Javascript?
Specifically in Dojo, as this doesn't seem to do the job
arguments.callee.caller
How can I get the function name inside a function in Javascript?
Specifically in Dojo, as this doesn't seem to do the job
arguments.callee.caller
Whether arguments.callee.name is defined or not depends on how the function was defined. It will be defined if the function was defined as Named function expression. Otherwise, you will not have this information.
setmain function does not have a name. You can give it a name after the function keyword if you want it to have a name: setmain: function setmain() {...}In dojo, if the function is a method of a class declared through dojo/_base/declare you can get it through :
arguments.callee.nom
See http://dojotoolkit.org/reference-guide/1.9/dojo/_base/declare.html
Every method mixed in by dojo/declare() or safeMixin() is annotated: a special property called nom is added. It contains a name of the method in question and used by inherited() and getInherited() to deduce the name of a superclass method. See safeMixin() for more details.