fromPairs

array

The inverse of toPairs; this method returns an object composed from key-value pairs.

Signature

fromPairs<T>(pairs: [string | number | symbol, T][]): Record<string | number | symbol, T>

Parameters

NameTypeDescription
pairs[string | number | symbol, T][]The key-value pairs

Returns

Record<string | number | symbol, T> - Returns the new object

Examples

Basic usage

import { fromPairs } from 'dashlite'

const result = fromPairs([['a', 1], ['b', 2]])
console.log(result)

Output:

{ 'a': 1, 'b': 2 }

Available since version 1.0.0