我需要在函数本身内显示函数名称:
而不是' functionName'在这段代码中,我需要它的名字。
function timeLoggingDecorator(f) {
return function() {
var start = Date.now();
console.log('Function has started: 'functionName' ');
var result = f.apply(this, arguments);
var finish = Date.now() - start;
console.log('Function has finished:','functionName', 'Working time:', finish, 'ms');
return result;
}
}
var func = function f(a, b) {
return (a * b * 2);
}
func = timeLoggingDecorator(func);
console.log( func(17505, 20500) );