This commit is contained in:
Angelos Chalaris
2017-12-27 11:02:46 +02:00
parent 0d9b02a3cb
commit b74eb9d9bd
45 changed files with 89 additions and 91 deletions

View File

@ -5,7 +5,7 @@ Given an array of valid property identifiers and an array of values, return an o
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 using `Array.reduce()`.
```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), {});
// zipObject(['a','b','c'], [1,2]) -> {a: 1, b: 2, c: undefined}
// zipObject(['a','b'], [1,2,3]) -> {a: 1, b: 2}
```