2024-05-06 20:40:05 +00:00
|
|
|
---
|
2024-10-30 17:34:11 +00:00
|
|
|
date: 2020-11-13
|
2024-05-06 20:40:05 +00:00
|
|
|
id: 6383dfcd-c925-4d33-8338-2da22edf7ef8
|
|
|
|
title: Object.getOwnPropertyDescriptors
|
|
|
|
---
|
|
|
|
|
|
|
|
# Description
|
|
|
|
|
|
|
|
Returns property descriptors of all known properties of an
|
|
|
|
[object](20200826201605-objects).
|
|
|
|
|
|
|
|
# Syntax
|
|
|
|
|
|
|
|
``` javascript
|
|
|
|
const obj = {
|
|
|
|
[Symbol("foo")]: 123,
|
|
|
|
get bar() {
|
|
|
|
return "abc";
|
|
|
|
},
|
|
|
|
};
|
|
|
|
console.log(Object.getOwnPropertyDescriptors(obj));
|
|
|
|
|
|
|
|
// Output:
|
|
|
|
// { [Symbol('foo')]:
|
|
|
|
// { value: 123,
|
|
|
|
// writable: true,
|
|
|
|
// enumerable: true,
|
|
|
|
// configurable: true },
|
|
|
|
// bar:
|
|
|
|
// { get: [Function: bar],
|
|
|
|
// set: undefined,
|
|
|
|
// enumerable: true,
|
|
|
|
// configurable: true } }
|
|
|
|
```
|