getPropertyDescriptors
Object.getOwnPropertyDescriptors is a static method of the Object class in JavaScript. It is used to retrieve all own property descriptors for a given object. Property descriptors are objects that describe the characteristics of a property, such as its value, writability, enumerability, and configurability.
When you call Object.getOwnPropertyDescriptors(obj), it returns an object where the keys are the names of the
Each property descriptor object returned by getOwnPropertyDescriptors contains one or more of the following attributes:
Value: The value of the property.
Writable: A boolean indicating whether the property's value can be changed.
Enumerable: A boolean indicating whether the property will be iterated over in for...in loops or Object.keys().
Configurable: A boolean indicating whether the property can be deleted or its attributes changed.
Get: A function to be called to retrieve the property's value.
Set: A function to be called to set the property's value.
This method is particularly useful for tasks like creating exact copies of objects, including non-enumerable properties,