This method can be used to retrieve the descriptor of a specific property.
此方法可用于检索特定属性的描述符。
Usage:
用法:
const propertyDescriptor = Object.getOwnPropertyDescriptor(object, propertyName)
Example:
例:
const dog = {}
Object.defineProperties(dog, {
breed: {
value: 'Siberian Husky'
}
})
Object.getOwnPropertyDescriptor(dog, 'breed')
/*
{
value: 'Siberian Husky',
writable: false,
enumerable: false,
configurable: false
}
*/
翻译自: https://flaviocopes.com/javascript-object-getownpropertydescriptor/