How to get the function name from within that function?

前端 未结 20 909
抹茶落季
抹茶落季 2020-11-22 16:06

How can I access a function name from inside that function?

// parasitic inheritance
var ns.parent.child = function() {
  var parent = new ns.parent();
  p         


        
20条回答
  •  逝去的感伤
    2020-11-22 16:26

    If I understood what you wanted to do, this is what I do inside a function constructor.

    if (!(this instanceof arguments.callee)) {
        throw "ReferenceError: " + arguments.callee.name + " is not defined";
    }
    

提交回复
热议问题