even more abused now w/ es6 arrow shorthand
let func = () => {}; let func = () => {};
console.log(func.name); // func
and in stack traces: let func = () => foo();
func()
results in: Uncaught ReferenceError: foo is not defined
func @ test.js:1All this time I've been using the full named function expressions over arrow functions just for the stack traces.
let doStuffCallback = () => {};
doStuff(doStuffCallback);
over: doStuff(function doStuffCallback() {
}); > let func = () => {}
undefined
> func.name
''
> function longfunc() {}
undefined
> longfunc.name
'longfunc'I also checked the online Babel REPL and verified that it works fine.
It looks like babel does this little nicety for stack-trace readability.
let func = () => {}
would be var func = function() {}
But even in that case, func.name is going to be "". var func = function func() {};
That's what the Babel REPL spits when you input the « let » statement.Your example is still an anonymous function just bound to a different context.