Javascript 获取原型函数名称
Javascript Get Prototype Function Name
免责声明:此代码是由另一位开发人员编写的,之前在项目中,我无法更改它 - 我也不允许。
我想做的是从 BaseDialog
.
获取 this.foobar()
中的父(?)函数的名称
可能吗?
var BaseDialog = new function () {
this.foobar = function () {
// get the prototype function name that called me? E.g DialogOne
}
}
DialogOne.prototype = BaseDialog;
function DialogOne() {
this.foobar();
}
DialogTwo.prototype = BaseDialog;
function DialogTwo() {
this.foobar();
}
let callerName = arguments.callee.caller.name.toString();
console.log("caller is " + callerName );
免责声明:此代码是由另一位开发人员编写的,之前在项目中,我无法更改它 - 我也不允许。
我想做的是从 BaseDialog
.
this.foobar()
中的父(?)函数的名称
可能吗?
var BaseDialog = new function () {
this.foobar = function () {
// get the prototype function name that called me? E.g DialogOne
}
}
DialogOne.prototype = BaseDialog;
function DialogOne() {
this.foobar();
}
DialogTwo.prototype = BaseDialog;
function DialogTwo() {
this.foobar();
}
let callerName = arguments.callee.caller.name.toString();
console.log("caller is " + callerName );