Create zipObject.md

Will also need to add a tag in the tag database
This commit is contained in:
Robert Mennell
2017-12-20 14:55:18 -08:00
committed by GitHub
parent 0995936760
commit 1f5585c385

11
snippets/zipObject.md Normal file
View File

@ -0,0 +1,11 @@
### zipObject
Given an Array of valid property identifiers and an Array of values, `zipObject` returns an object mapping the properties to the values
Since an object can have undefined values but not undefined property pointers, the Array of properties is used to decide the structure of the resulting object
```js
const zipObject = (props, values) => props.reduce( ( obj, prop, index ) => (obj[prop] = values[index], obj), {})
/*
zipObject(['a','b','c'], [1,2])
*/
```