好的,我刚开始使用javascript,你可以这样做:执行:
x ('y'). z (). b ('c')
这有输出:
x y
z
b c
我一直在测试原型,但它们留在第一部分
Object.prototype.getNameOfCall = function (fn) {
var e = fn.arguments [0]
for (var p in this)
if (this [p] === fn)
return p + '' + e;
throw "Callback not in object.";
};
x = function (y) {
console.log (this.getNameOfCall (arguments.callee)); // MyClass
console.log (this.getOwnPropertyNames)
};
x ('y')
我不知道我是否走在正确的轨道上,提前谢谢。
我不清楚你为什么要这样,但你可以反思被调用的函数:
function x () {
console.log(`${arguments.callee.name} ${[].join.call(arguments, ' ')}`)
}
x('y', 'z')
您必须将此行添加到要以此方式登录的每个功能。