Last active
February 25, 2020 09:19
-
-
Save toxi-kb/2f031d30cd0f5c4ec2194beee60e3e12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Can handle only simple keys | |
| const logValues1 = (obj, keys) => { | |
| keys.forEach(key => console.log(obj[key])); | |
| } | |
| // Can handle complex keys | |
| const logValues2 = (obj, keys) => { | |
| keys.forEach(key => console.log(_.at(obj, key))); | |
| } | |
| const data = { user: { name: 'Vadim', age: 29 }}; | |
| // This don't working | |
| logValues1(data, ['user.name', 'user.age']); | |
| // This working | |
| logValues2(data, ['user.name', 'user.age']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment