JavaScript Object.getOwnPropertyDescriptor() Method

The Object.getOwnPropertyDescriptor method allows to query the full information about a property and returns a property descriptor for an own property (that is, one directly present on an object and not in the object's prototype chain) of a given object.

Syntax:

Parameter

obj: It is the object in which to look for the property.

Prop: It is the name of the property whose description is to be retrieved.

Return value:

It returns a property descriptor of the given property if it exists on the object.

Browser Support:

Chrome4
EdgeYes
Firefox12
Opera4

Example 1

Output:

true
true
42
34

Example 2

Output:

true
true
42

Example 3

Output:

true
56





Latest Courses