getDescriptor
Commons
stable
Walks the prototype chain of an object and returns the first property descriptor found for the given key. Works across the full inheritance hierarchy, not just own properties.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- objrequiredany
- The object (or instance) to inspect. The function walks up via Object.getPrototypeOf until the key is found or the chain ends.
- keyrequiredPropertyKey
- The property key to look for (string, number, or symbol).
API
Return value
The value returned by this util.
- The first matching PropertyDescriptor, or undefined when the key is not found anywhere in the chain.
Usage
Examples
Ready-to-paste usage snippets.
Read a getter from a prototype