JavaScript: Function.prototype.name

By Xah Lee. Date: . Last updated: .
f.name
Value is the name of the function, or empty string.
// arrow function assigned to a var, has a name of the var
const f1 = (() => {});
console.log(f1.name === "f1");

// not own property
console.log( Reflect.apply( Object.hasOwnProperty , f1, ["f1"] ) === false );

// anon arrow function has name of empty string
console.log((() => {}).name === "");
// function declaration
function fd() {}
console.log(fd.name === "fd");

// function expression assigned to a var
const fe = function () {}
console.log(fe.name === "fe");

// anon function expression has name of empty string
console.log((function () {}).name === "");
BUY ΣJS JavaScript in Depth