Javascript - Object Object.getOwnPropertyDescriptors()

Introduction

Object.getOwnPropertyDescriptors(), new in ES2017, examines the description of all the own properties of the given object.

The property in a JavaScript object normally consists of a name that is a string and a property descriptor.

The descriptor is a record of the property value, Boolean writable, a get function, a set function, a Boolean configurable, and a Boolean enumerable.

Demo

const myObj = { 
    [Symbol('mySymbol')]: 42, 
    get random() { return 'test' }, 
}; // w  ww  . j av a2 s  .  co  m

console.log(Object.getOwnPropertyDescriptors(myObj));

Result