Created
July 23, 2021 15:51
-
-
Save Bengejd/86a79b52f8210488d032bbf551d2c88c to your computer and use it in GitHub Desktop.
Accessing nested JavaScript objects and arrays by string path
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
const resolve = (path, obj) => path.split(".").reduce((prev, curr) => prev ? prev[curr] : null, obj || self); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment