javascript - arguments.callee.toString() and arguments.callee.name does not return function name

后端 未结 8 2047
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 04:30

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(/func         


        
8条回答
  •  执笔经年
    2021-01-05 05:04

    On firefox 3.5, Safari 5, and Chrome 6.0 you can use:

    function myFunctionName() {
     alert("Name is " + arguments.callee.name );
    }
    
    myFunctionName();
    

    You can also get the function that called the current one using arguments.callee.caller.

提交回复
热议问题