Files
30-seconds-of-code/snippets/object-from-key-value-pairs.md
2017-12-12 07:11:37 -05:00

9 lines
225 B
Markdown

### Object from key-value pairs
Use `map()` to create objects for each key-value pair, combine with `Object.assign()`.
```js
const objectFromPairs = arr =>
Object.assign(...arr.map( v => {return {[v[0]] : v[1]};} ));
```