![]() |
VOOZH | about |
The Object.getOwnPropertyDescriptor() method in JavaScript is a standard built-in object that enables the full information on a property to be accessed and returns a property descriptor for the own property of a given object.
Syntax:
Object.getOwnPropertyDescriptor( obj, prop )
Parameters: This method accepts two parameters as mentioned above and described below:
Return value: This method returns a property descriptor of the given property or undefined depending upon the existence of the object.
Below examples illustrate the Object.getOwnPropertyDescriptor() method in JavaScript:
Example 1: In this example, we will check if an object contains some property or not using the Object.getOwnPropertyDescriptor() method in JavaScript.
Output:
true true "GeeksforGeeks" "Best Platform" true "And Computer science portal"
Example 2: In this example, we will check if an object contains some property or not using the Object.getOwnPropertyDescriptor() method in JavaScript.
Output:
Object { get: get foo() { return 17; }, set: undefined, enumerable: true, configurable: true }
Object { value: 42, writable: true, enumerable: true, configurable: true }
Object { value: 73, writable: true, enumerable: true, configurable: true }
Object { value: 8675309, writable: false, enumerable: false, configurable: false }
We have a complete list of Javascript Object methods, to check those please go through this JavaScript Object Complete Reference article.
Supported Browsers: The browsers supported by Object.getOwnPropertyDescriptor() method are listed below: