JavaScript Object fromEntries() method
creates an object from a list of key/value pairs

Object.fromEntries() static method creates an object from a list of key/value pairs.

Object.fromEntries() reverses the effects of Object.entries()

Object.entries() will convert our array and return a new nested array of key/value pairs.

Object.fromEntries() will turn that back to an object.

syntax

Object.fromEntries(iterable)

iterable can be an Array or Map, containing a list of objects. Each object should have two properties ↴

1. A string or symbol representing the property key.

2. The property value.

Typically, this object is implemented as a two-element array, with the first element being the property key and the second element being the property value.

Iterable implemented using an Array ↴

const array = [['key 1', 'value 1'], ['key 2', 'value 2']];

Object.fromEntries(array); returns ↴

{key 1: 'value 1', key 2: 'value 2'}

Iterable implemented using a Map ↴

const map = new Map([['key 1', 'value 1'], ['key 2', 'value 2']]);

Object.fromEntries(map); returns ↴

{key 1: 'value 1', key 2: 'value 2'}

syntax description
create an object from a list of key/value pairs
Object.fromEntries(iterable)