💾.assignDescriptors()
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
JS ⟩ objects ⟩ extending objects ⟩ mixin ⟩ 💾 Object.assignDescriptors()
☢️ Alert:
Don't use Object.assign() with sources that have getters, the inner states of the sources may change❗❗❗
replit, compare with obj.mergeWith()
/*****************************************************************
* Object.assignDescriptors() *
*****************************************************************
*
* • copies property descriptors from sources into the target
* instead of just copying property values.
*
* • copies all own properties (both enumerable and non-enumerable).
* • copies getters from sources and overwrites setters in the target
* rather than invoking those getters/setters.
*
* • propagates any TypeErrors thrown by `Object.defineProperty()`: