Object.fromEntries()

ES2019+

Transforms a list of key-value pairs into an object.

Syntax

Object.fromEntries(iterable)

Parameters

iterable Iterable

An iterable such as Array or Map containing key-value pairs

Return Value

Object

A new object whose properties are given by the entries

Examples

JavaScript
const entries = [['a', 1], ['b', 2]];
console.log(Object.fromEntries(entries));
Output:
// { a: 1, b: 2 }

Related Methods