Object.fromEntries
Transforms a list of key-value pairs into an object
Syntax
Object.fromEntries(iterable)Parameters
| Parameter | Type | Description |
|---|---|---|
| iterable | Iterable<[string, any]> | An iterable of key-value pairs (like a Map or array of pairs) |
Return Value
A new object whose properties are given by the entries
Examples
const entries = [['a', 1], ['b', 2], ['c', 3]];
const obj = Object.fromEntries(entries);
console.log(obj); // { a: 1, b: 2, c: 3 }const map = new Map([['name', 'Alice'], ['age', '30']]);
const obj = Object.fromEntries(map);
console.log(obj); // { name: 'Alice', age: '30' }const params = new URLSearchParams('foo=bar&baz=qux');
const obj = Object.fromEntries(params);
console.log(obj); // { foo: 'bar', baz: 'qux' }Understanding Object.fromEntries
The Object.fromEntries method in JavaScript transforms a list of key-value pairs into an object. It belongs to the Object object and is one of the most widely used methods for working with object values in modern JavaScript and TypeScript applications.
The method signature is Object.fromEntries(iterable). It accepts 1 parameter: iterable. When called, it returns a new object whose properties are given by the entries. Understanding when and how to use fromEntries() helps you write more expressive, readable code.
Common use cases for Object.fromEntries include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like object-entries, object-keys, object-values, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Object.fromEntries is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More Object Methods
Other methods in the Object object
Related Tools
More Object Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.