Get function name

OSCC · 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);
let m = functionName(Math.max)(5, 6);
// max (logged in debug channel of console)
// m = 6

Recommended snippets

  • Nth argument

    JavaScript, Function

    Creates a function that gets the argument at index n.

  • Logical complement

    JavaScript, Function

    Returns a function that is the logical complement of the given function, fn.

  • Logical or for functions

    JavaScript, Function

    Checks if at least one function returns true for a given set of arguments.