Skip to content

Instantly share code, notes, and snippets.

@Lodo4ka
Created March 22, 2020 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lodo4ka/55aae6c9b018880a8aa049adc024c218 to your computer and use it in GitHub Desktop.
Save Lodo4ka/55aae6c9b018880a8aa049adc024c218 to your computer and use it in GitHub Desktop.
get key nested object any depths
const getIn = (data, keys) => {
let current = data;
for (const key of keys) {
if (!has(current, key)) {
return null;
}
current = current[key];
}
return current;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment