The object for which to get all own property descriptors
An object containing all own property descriptors of the given object
const obj = {
get foo() { return 17; },
bar: 42
};
const descriptors = objGetOwnPropertyDescriptors(obj);
// descriptors is:
// {
// foo: {
// configurable: true,
// enumerable: true,
// get: [Function: get foo],
// set: undefined
// },
// bar: {
// configurable: true,
// enumerable: true,
// value: 42,
// writable: true
// }
// }
// This method can be used to create a shallow copy including getters and setters
const shallowCopy = objCreate(
objGetPrototypeOf(obj),
objGetOwnPropertyDescriptors(obj)
);
The objGetOwnPropertyDescriptors() method returns all own property descriptors of a given object.