Get function name

JavaScript, Function · Oct 19, 2020

Logs the name of a function.

  • Use console.debug() and the name property of the passed function to log the function's name to the debug channel of the console.
  • Return the given function fn.
const functionName = fn => (console.debug(fn.name), fn);
let m = functionName(Math.max)(5, 6);
// max (logged in debug channel of console)
// m = 6

More like this

  • Where and how can I use memoization in JavaScript?

    Learn different ways to memoize function calls in JavaScript as well as when to use memoization to get the best performance results.

    JavaScript, Function · Nov 7, 2021

  • Nth argument

    Creates a function that gets the argument at index n.

    JavaScript, Function · Oct 21, 2020

  • Function property names

    Gets an array of function property names from own (and optionally inherited) enumerable properties of an object.

    JavaScript, Object · Oct 20, 2020