Simplify objectFromPairs
This commit is contained in:
@ -5,7 +5,7 @@ Creates an object from the given key-value pairs.
|
||||
Use `Array.reduce()` to create and combine key-value pairs.
|
||||
|
||||
```js
|
||||
const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
|
||||
const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {});
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user