Skip to content

fromEntries

The fromEntries() method builds an object from an array of key-value pairs.

Interactive example

Syntax

typescript
function fromEntries<
	GenericKey extends ObjectKey, 
	const GenericEntry extends readonly [GenericKey, unknown]
>(
	entries: readonly GenericEntry[]
): ComputeEntries<GenericEntry>;

Parameters

  • input: An array of tuples [key, value].

Return value

An object built from the key-value pairs, with strict typing that preserves the exact types.

See also

  • entries - Returns an array of an object's key-value pairs
  • entry - Creates a typed key-value pair

Sources

Released under the MIT license.