Object.getOwnPropertyDescriptor()
方法可以获取对象自有 Property 的某个 Attributes。
Object.getOwnPropertyDescriptor(O, Property);
参数 | 说明 | 类型 |
---|---|---|
O | 需要查找的目标对象 | object |
Property | 目标对象的 Property | string |
const foo = { a: 1 };Object.getOwnPropertyDescriptor(foo, 'a');// Object {// value: "a",// writable: true,// enumerable: true,// configurable: true,// }