Files
30-seconds-of-code/snippets/js/s/function-name.md
2023-05-07 16:07:29 +03:00

522 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Get function name snippet javascript
function
flower-portrait-5 2020-10-19T22:49:51+03:00

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