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

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

obj
requis
any
The object (or instance) to inspect. The function walks up via Object.getPrototypeOf until the key is found or the chain ends.
key
requis
PropertyKey
The property key to look for (string, number, or symbol).

API

Valeur de retour

La valeur retournée par cet util.

The first matching PropertyDescriptor, or undefined when the key is not found anywhere in the chain.

Usage

Exemples

Extraits de code prêts à coller.

Read a getter from a prototype

typescript