![]() |
VOOZH | about |
JavaScript handler.getOwnPropertyDescriptor() method in Javascript is a trap for the Object.getOwnPropertyDescriptor() method. A property cannot be reported as non-existent if it exists as a non-configurable own property of the target object.
Syntax:
const p = new Proxy(target, {
getOwnPropertyDescriptor: function(target, prop) {
}
});
Parameters: This method accepts two parameters as mentioned above and described below:
Return value: This method returns an object or undefined.
Below examples illustrate the handler.getOwnPropertyDescriptor() method in JavaScript:
Example 1: In this example, we will see the use of handler.getOwnPropertyDescriptor() method in JavaScript.
Type : num 5 Type : bool true
Example 2: In this example, we will see the use of handler.getOwnPropertyDescriptor() method in JavaScript.
Property : VAL 10 undefined
The browsers are supported by handler.getOwnPropertyDescriptor() method is listed below:
We have a complete list of Javascript Proxy/handler methods, to check those go through the Javascript Proxy/handler Reference article.