Files
30-seconds-of-code/snippets/function-name.md
Angelos Chalaris 61200d90c4 Kebab file names
2023-04-27 21:58:35 +03:00

521 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
Get function name function flower-portrait-5 2017-12-17T17:55:51+02:00 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