CKTIS / JavaScript
Object.fromEntries — an object from key–value pairs
Object.fromEntries creates a new object from an iterable collection of key–value entries. It supports string and symbol keys; repeated keys keep the last value. Use it to transform entries or convert a Map into an object.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
Object.fromEntries(iterable)Object.fromEntries(iterable) is a static method introduced in ECMAScript 2019, not a Web API. It accepts an iterable, such as an array of pairs or a Map, and returns a new ordinary object with Object.prototype as its prototype. Check availability in the target environment with typeof Object.fromEntries === "function"; the Node version used in a repository does not establish browser support.
Each entry must be an object: the method reads its properties 0 and 1 as the key and value. Entries themselves need not be iterable. A missing property 1 produces the value undefined, and extra elements are ignored. Non-iterable input or a primitive entry causes a TypeError.
To obtain a property key, the method first converts an object key to a primitive. If the primitive is a symbol, it is used unchanged; otherwise it is converted to a string. If keys repeat after conversion, the last value wins. The result has own data properties that are writable, enumerable, and configurable. A "__proto__" entry creates an own property instead of changing the prototype.
A common workflow is Object.entries(obj), followed by map or filter, then Object.fromEntries(...). This is not a complete inverse: Object.entries omits symbols and non-enumerable properties, and descriptors are not preserved. Object values remain references—this does not produce a deep copy.
Examples
const token = Symbol("token");
const entries = [["score", 10], ["score", 20], [token, "ok"]];
const result = Object.fromEntries(entries);
console.log(result.score);
console.log(result[token]);
console.log(Object.entries(result).length);Result
20 ok 1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.