Get JavaScript Function Names, Parameters, and Object Property Names
Modern functions expose a name property:
function calculateTotal(price, quantity) {}
console.log(calculateTotal.name); // calculateTotal
Object property names are available through standard reflection APIs:
const value = {name: "Tom", age: 18};
console.log(Object.keys(value));
console.log(Object.getOwnPropertyNames(value));
console.log(Reflect.ownKeys(value));
JavaScript has no reliable standard API that returns a function's declared parameter names. Parsing Function.prototype.toString() breaks on default values, destructuring, comments, transpilation, native functions, and minification. Use explicit metadata when parameter names are part of an application protocol.
Function names can also change or disappear after bundling and minification, so do not use them as stable identifiers. Closures hide lexical variables by design; they cannot be enumerated through normal reflection. For dependency injection, serialization, or routing, prefer explicit keys, decorators, schemas, or configuration.