Files
30-seconds-of-code/snippets/object-from-key-value-pairs.md
2017-12-10 15:02:07 +02:00

9 lines
223 B
Markdown

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