Skip to content

Instantly share code, notes, and snippets.

@toxi-kb
Last active February 25, 2020 09:19
Show Gist options
  • Select an option

  • Save toxi-kb/2f031d30cd0f5c4ec2194beee60e3e12 to your computer and use it in GitHub Desktop.

Select an option

Save toxi-kb/2f031d30cd0f5c4ec2194beee60e3e12 to your computer and use it in GitHub Desktop.
// 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