I always thought that anonymous functions have no name
but that's not the case when assigned:
const foo = () => {};
console.log(foo.name); // expected "" but got "foo"
That got me wondering whether the variable name is also local to the anonymous function:
const fact = n => n > 0 ? n * fact(n - 1) : 1;
// ^
// |
// Is fact a local variable?
If it's not local then for recursive functions like fact
we need to travel up the scope chain. Obviously, this is not a major performance issue. Nevertheless, I'm curious to know whether the function variable name is local within the anonymous function.