Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Function

Object.fromEntries

Object.fromEntries() creates a new object from an iterable of key-value pairs. It accepts sources such as arrays and Maps, including entries with symbol keys.

Since
2019

How it works

Object.fromEntries() consumes an iterable that yields two-item entries. It creates a new ordinary object, using each entry's first item as a property key and its second item as that property's value; symbol keys are supported as well as string keys.

Syntax

Object.fromEntries(iterable)

Parameters

NameTypeDescription
iterableIterableAn iterable, such as an Array or Map, whose iterator produces two-element array-like entries. The first item is a string or symbol key, and the second is its value.

Returns

A new object whose properties are given by the entries of the iterable.

Key points

  • It is a static Object method that constructs an object from key-value pairs.
  • The argument can be any iterable, including an array or a Map.
  • Each entry's first position supplies a string or symbol property key.
  • Each entry's second position supplies the value stored under that key.
  • The return value is a newly created object populated from the iterable's entries.
  • It provides the construction counterpart to Object.entries() for converting between objects and key-value pairs.

Common mistakes

  • The method ignores the constructor or receiver used to call it; it always creates a new ordinary object rather than an instance of another constructor.
  • Unlike Object.entries(), it accepts symbol property keys, so converting entries is not limited to string-keyed properties.

Example: Convert a Map to an object

const entries = new Map([
  ["language", "JavaScript"],
  ["version", 2024],
]);

const result = Object.fromEntries(entries);
console.log(result); // { language: "JavaScript", version: 2024 }

Converts a Map's key-value pairs into an ordinary object.

When to use it

Map conversion

Transform a Map into a plain object for APIs or serialization.

Pipeline transformations

Build an object from filtered or mapped key-value pairs.

Symbol-keyed records

Construct objects while retaining symbol-keyed properties.

Interview questions

QWhat does Object.fromEntries() do?

It accepts an iterable whose iterator produces two-element array-like values. The first element becomes the property key, and the second becomes its value; the result is a new object.

Follow-up: What happens with a Map? A Map is iterable over its key-value pairs, so it can be passed directly without first converting it to an array.

QWhat input shape does it require?

The input must implement [Symbol.iterator](), and each produced entry must provide a key in position 0 and a value in position 1. Arrays and Maps are typical inputs.

Follow-up: Why can a custom iterable be used? Because the method depends on the iterable protocol rather than on a specific collection type.

QHow does Object.fromEntries() relate to Object.entries()?

It is the reverse of Object.entries() in the usual string-keyed case: entries turns an object's own enumerable string properties into pairs, while fromEntries builds an object from pairs. fromEntries additionally supports symbol keys.

Follow-up: Does it preserve the source object's prototype? No. The method creates a new ordinary object rather than cloning the source object or using a custom constructor.

  • Object.entries()
  • Object.keys()
  • Object.values()
  • Map

Source: Object.fromEntries () - JavaScript | MDN. Checked 2026-10-15.