fromEntries
fromEntries() function
Returns an object from string keyed-value pairs.
Signature:declare function fromEntries<U extends [Key, any] | readonly [Key, any], T extends Iterable<U> | AsyncIterable<U>>(iterable: T): ReturnValueType<T, {
[K in IterableInfer<T> as K[0]]: K[1];
}>;
Example
const arr = [
["a", 1],
["b", true],
["c", "hello"],
["d", { d1: 1, d2: 3 }],
] as (
| ["a", number]
| ["b", boolean]
| ["c", string]
| ["d", { d1: number, d2: number; }]
)[];
fromEntries(arr); // { a: 1, b: true, c: 'hello', d: { d1: 1, d2: 3 } }
see entries