0

I need function name to be shown inside the function itself:

Instead of 'functionName' in this code, I need it's name.

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) );
Archie
  • 86
  • 1
  • 1
  • 6

0 Answers0