JavaScript (ES2026) reference · Object Methods

JavaScript Object.fromEntries() Method

Build an object from an iterable of [key, value] pairs, such as an array or a Map. The opposite of Object.entries().

JavaScript (ES2026) Since ES2019

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Object.fromEntries(iterable)

Parameters

ParameterDescription
iterable Pairs such as [["a", 1]] or a Map.

Return value

A new object.

Examples

From pairs or a MapTry it yourself
console.log(Object.fromEntries([["a", 1], ["b", 2]]));
console.log(Object.fromEntries(new Map([["x", true]])));

Output

{ a: 1, b: 2 }
{ x: true }
Map over an object's valuesTry it yourself
const prices = { tea: 3, cake: 4 };
const withTax = Object.fromEntries(Object.entries(prices).map(([k, v]) => [k, Math.round(v * 1.2 * 100) / 100]));
console.log(withTax);

Output

{ tea: 3.6, cake: 4.8 }

Version history

VersionChange
JavaScript ES2019Added

In other languages

Was this page helpful?