Last active
June 18, 2019 10:07
-
-
Save nojimage/a0f2df9bc76285f397dc1537d1f3dd64 to your computer and use it in GitHub Desktop.
This file contains 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
function hash_get(key, haystack) { | |
const keys = key.split('.'); | |
if (!Object.prototype.hasOwnProperty.call(haystack, keys[0])) { | |
return null; | |
} | |
const matched = haystack[keys[0]]; | |
if (keys.length === 1) { | |
return matched; | |
} | |
return hash_get(keys.slice(1).join('.'), matched); | |
} | |
export default hash_get; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example: