In contrast to the built-in Object.getOwnPropertyDescriptor(), this function returns null if provided undefined or null, rather than throwing an error.
In contrast to the built-in Object.getOwnPropertyDescriptor(), this function returns null if an object does not have a provided property, rather than undefined.
Parameters
value: any
input object
property: string | symbol
property
Returns
TypedPropertyDescriptor<any> | null
property descriptor or null
Example
var obj = {
'beep': 'boop',
'foo': 3.14
};
var desc = propertyDescriptorIn( obj, 'foo' );
// returns {'configurable':true,'enumerable':true,'writable':true,'value':3.14}
Returns a property descriptor for an object's own or inherited property.
Notes
Object.getOwnPropertyDescriptor()
, this function returnsnull
if providedundefined
ornull
, rather than throwing an error.Object.getOwnPropertyDescriptor()
, this function returnsnull
if an object does not have a provided property, rather thanundefined
.