Object.fromEntries

Specification
Proposal repo

Modules

es.object.from-entries.

Built-ins signatures

class Object {
  static fromEntries(iterable: Iterable<[key, value]>): Object;
}

Entry points

core-js/proposals/object-from-entries
core-js(-pure)/es|stable|actual|full/object/from-entries

Examples

const map = new Map([['a', 1], ['b', 2]]);
Object.fromEntries(map); // => { a: 1, b: 2 }

class Unit {
  constructor(id) {
    this.id = id;
  }
  toString() {
    return `unit${ this.id }`;
  }
}

const units = new Set([new Unit(101), new Unit(102)]);

Object.fromEntries(units.entries()); // => { unit101: Unit { id: 101 }, unit102: Unit { id: 102 } }