JS: Object.getOwnPropertyDescriptors
New in JS2017.
Object.getOwnPropertyDescriptors(obj)
-
Return Property Descriptor of all own properties of a object.
The return value is a object, has this form
{ k1: descriptor1, k2: descriptor2, etc }
.If obj is not a object, it is first converted to a object type.
// object with a string key and symbol key const jj = { "p": 3, [Symbol()]: 4, }; console.log( Object.getOwnPropertyDescriptors(jj), ); /* { p: { value: 3, writable: true, enumerable: true, configurable: true }, [Symbol()]: { value: 4, writable: true, enumerable: true, configurable: true } } */
// If obj is not a object, it is first converted to a object type console.log(Object.getOwnPropertyDescriptors(3)); // {}