Created
March 22, 2020 15:09
-
-
Save Lodo4ka/55aae6c9b018880a8aa049adc024c218 to your computer and use it in GitHub Desktop.
get key nested object any depths
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
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