Concepts
Descriptor-preserving shallow copy
Copies ordinary own property descriptors and shares their referenced values and the prototype. Does not recreate internal slots or private elements of arbitrary instances.
Formal Syntax & Structure
javascript syntaxjavascript
Object.create(Object.getPrototypeOf(source), Object.getOwnPropertyDescriptors(source))Working Example
Example Snippetjavascript
const a={};Object.defineProperty(a,"n",{value:4});const b=Object.create(Object.getPrototypeOf(a),Object.getOwnPropertyDescriptors(a));console.log(b.n,Object.keys(b).length);