I've witnessed the behavior in action and later discovered the concept of "name inference" for anonymous functions (most notably the new arrow functions) but I haven't been able to find where this behavior is defined. For reference:
// Arrow functions are inherently anonymous so this shouldn't work
const foo = () => {};
console.log(foo.name); // outputs "foo"
const bar = function() {};
console.log(bar.name); // outputs "bar"
// vs
console.log((() => {}).name) // outputs ""
console.log((function() {}).name) // outputs ""
The closest thing I've found is on MDN which attributes it to "new in ECMAScript 2015". I tried to search the ES2015 spec with no luck. This seems to be a largely unknown but useful capability of modern ES for which little documentation actually exists.
Can anyone provide a reference to the canonical spec for this?