Update zipObject.md
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
### zipObject
|
### zipObject
|
||||||
|
|
||||||
Given an Array of valid property identifiers and an Array of values, `zipObject` returns an object mapping the properties to the values
|
Given an Array of valid property identifiers and an Array of values, `zipObject` returns an object associating 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
|
|
||||||
|
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 through a `reduce`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const zipObject = (props, values) => props.reduce( ( obj, prop, index ) => (obj[prop] = values[index], obj), {})
|
const zipObject = (props, values) => props.reduce( ( obj, prop, index ) => (obj[prop] = values[index], obj), {})
|
||||||
|
|||||||
Reference in New Issue
Block a user