How can I get the name of function inside a JavaScript function?

后端 未结 3 986
暖寄归人
暖寄归人 2020-12-13 09:12

How is it possible to learn the name of function I am in?

The below code alerts \'Object\'. But I need to know how to alert \"Outer.\"

function Oute         


        
3条回答
  •  难免孤独
    2020-12-13 10:10

    This will work:

    function test() {
      var z = arguments.callee.name;
      console.log(z);
    }
    

提交回复
热议问题