Object to key-value pairs description, linting, build README
This commit is contained in:
@ -447,6 +447,8 @@ const objectFromPairs = arr => arr.reduce((a, v) => (a[v[0]] = v[1], a), {});
|
|||||||
|
|
||||||
### Object to key-value pairs
|
### Object to key-value pairs
|
||||||
|
|
||||||
|
Use `Object.keys()` and `Array.map()` to iterate over the object's keys and produce an array with key-value pairs.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
||||||
// objectToPairs({a: 1, b: 2}) -> [['a',1],['b',2]])
|
// objectToPairs({a: 1, b: 2}) -> [['a',1],['b',2]])
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
### Object to key-value pairs
|
### Object to key-value pairs
|
||||||
|
|
||||||
|
Use `Object.keys()` and `Array.map()` to iterate over the object's keys and produce an array with key-value pairs.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
||||||
// objectToPairs({a: 1, b: 2}) -> [['a',1],['b',2]])
|
// objectToPairs({a: 1, b: 2}) -> [['a',1],['b',2]])
|
||||||
|
|||||||
Reference in New Issue
Block a user