DEV Community

Discussion on: Function Declaration VS Function Expression In JavaScript

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Function expressions can indeed use a function name - and it can be a good idea to do so - the names will show up in debug traces and can make following the trace much easier. This is perfectly valid:

const myFunc = function doStuff() { console.log('hello') }
Enter fullscreen mode Exit fullscreen mode

The resulting function will be callable with myFunc() and will have the name doStuff in debug/stack traces