Every function gets two own properties at creation, through SetFunctionName and SetFunctionLength. Both are { writable: false, enumerable: false, configurable: true }, so assignment fails (a TypeError in strict code) but Object.defineProperty can replace them.
name. A declaration or named expression uses its own identifier. An anonymous function or class gets a name only when the spec runs NamedEvaluation on it, which happens when IsAnonymousFunctionDefinition is true (a function or class with no own name, parentheses allowed) in these positions:
- an initializer of a plain identifier:
const f = () => {},let g = function () {}, a parameter or destructuring default; - assignment to a plain identifier, including
||=,&&=,??=; - an object-literal property or class field: the property key, so
{ run: () => {} }gives'run'; export default function () {}, which gives'default'.
Assigning to a member — obj.run = function () {} — is not one of them, so name is ''. Other forms add a prefix or wrapper: getters and setters get 'get x'/'set x', Symbol keys become '[description]', private methods '#x', bound functions 'bound f', and new Function gives 'anonymous'.
length. For ordinary functions it's ExpectedArgumentCount: the number of formal parameters to the left of the first one with a default or the rest parameter. A destructuring pattern counts as one parameter. Built-ins have a length fixed by their spec entry: Math.max.length is 2, Array.prototype.push.length is 1.
Neither property changes behaviour — you can call any function with any number of arguments. Code reads them for debugging and stack traces (name) and for arity-based helpers like auto-currying (length). Both are fragile there: minifiers may rename functions, and adding a default parameter silently lowers length.