Object.getOwnPropertyDescriptors

Specification
Proposal repo

Modules

es.object.get-own-property-descriptors.

Built-ins signatures

class Object {
  static getOwnPropertyDescriptors(object: any): { [property: PropertyKey]: PropertyDescriptor };
}

Entry points

core-js/proposals/object-getownpropertydescriptors
core-js(-pure)/es|stable|actual|full/object/get-own-property-descriptors

Examples

const object = { a: '1' };
Object.defineProperty(object, 'notWritable', { value: true, writable: false, enumerable: true });
// Shallow object cloning with prototype and descriptors:
Object.create(Object.getPrototypeOf(object), Object.getOwnPropertyDescriptors(object)); // => { a: '1', notWritable: true }

const target = { a: '9' };
const source = { b: '8' };
Object.defineProperty(source, 'notWritable', { value: true, writable: false, enumerable: true });
// Mixin:
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); // => { a: '9', b: '8', notWritable: true }