Update deepMapKeys.md
This commit is contained in:
@ -4,7 +4,8 @@ Deep maps an object keys.
|
||||
|
||||
Creates an object with the same values as the provided object and keys generated by running the provided function for each key.
|
||||
|
||||
Use Object.keys(obj) to iterate over the object's keys. Use Array.prototype.reduce() to create a new object with the same values and mapped keys using fn.
|
||||
Use `Object.keys(obj)` to iterate over the object's keys.
|
||||
Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.
|
||||
|
||||
```js
|
||||
const deepMapKeys = (obj, f) => (
|
||||
@ -23,12 +24,9 @@ const deepMapKeys = (obj, f) => (
|
||||
```
|
||||
|
||||
```js
|
||||
'use strict';
|
||||
const obj = {
|
||||
foo:'1',
|
||||
isnull:null,
|
||||
nested:{
|
||||
bar:'1',
|
||||
child:{
|
||||
withArray:[
|
||||
{
|
||||
@ -37,15 +35,12 @@ const obj = {
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const upperKeysObj = deepMapKeys(obj, (key) => key.toUpperCase());
|
||||
/*
|
||||
Formatted JSON Data
|
||||
{
|
||||
"FOO":"1",
|
||||
"ISNULL":null,
|
||||
"NESTED":{
|
||||
"BAR":"1",
|
||||
"CHILD":{
|
||||
"WITHARRAY":[
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user