---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# handler.getOwnPropertyDescriptor()

The **`handler.getOwnPropertyDescriptor()`** method is a trap for [`Object.getOwnPropertyDescriptor()`](../../../globals/Object/getOwnPropertyDescriptor.mdx).



## Syntax

```js
new Proxy(target, {
  getOwnPropertyDescriptor(target, prop) {
  }
});
```

### Parameters

The following parameters are passed to the `getOwnPropertyDescriptor()` method. `this` is bound to the handler.

- `target`
  - : The target object.
- `prop`
  - : The name of the property whose description should be retrieved.

### Return value

The `getOwnPropertyDescriptor()` method must return an object or `undefined`.

## Description

The **`handler.getOwnPropertyDescriptor()`** method is a trap for [`Object.getOwnPropertyDescriptor()`](../../../globals/Object/getOwnPropertyDescriptor.mdx).

### Interceptions

This trap can intercept these operations:

- [`Object.getOwnPropertyDescriptor()`](../../../globals/Object/getOwnPropertyDescriptor.mdx)
- [`Reflect.getOwnPropertyDescriptor()`](../../../globals/Reflect/getOwnPropertyDescriptor.mdx)

Or any other operation that invokes the `[[GetOwnProperty]]` [internal method](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy#object_internal_methods).

### Invariants

If the following invariants are violated, the trap throws a [`TypeError`](../../../globals/TypeError/TypeError.mdx) when invoked.

- `getOwnPropertyDescriptor()` must return an object or `undefined`.
- A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target object.
- A property cannot be reported as non-existent, if it exists as an own property of the target object and the target object is not extensible.
- A property cannot be reported as existent, if it does not exists as an own property of the target object and the target object is not extensible.
- A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or if it exists as a configurable own property of the target object.
- The result of `Object.getOwnPropertyDescriptor(target)` can be applied to the target object using `Object.defineProperty()` and will not throw an exception.
