Forum Discussion

blearyeye's avatar
blearyeye
Contributor
13 years ago
Solved

Getting current function name

Is there a way to reflect on a script in order to get the current function name? For example,



     function Afunction() {

       var theName = FunctionName();

     }



so that theName would contain "Afunction"
  • Hi,



    It should be arguments.callee.toString().match(/function (\w*)/)[1] like this:

    function Afunction()

    {

      var theName = arguments.callee.toString().match(/function (\w*)/)[1];

    }

2 Replies

  • Hi,



    It should be arguments.callee.toString().match(/function (\w*)/)[1] like this:

    function Afunction()

    {

      var theName = arguments.callee.toString().match(/function (\w*)/)[1];

    }