wiki/content/20201113102125-object_getownpropertydescriptors.md

630 B

date id title
2020-11-13 6383dfcd-c925-4d33-8338-2da22edf7ef8 Object.getOwnPropertyDescriptors

Description

Returns property descriptors of all known properties of an object.

Syntax

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 } }