Skip to content

Instantly share code, notes, and snippets.

@schester44
Created October 16, 2018 15:40
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 schester44/d71e02e230ee457437f6482a22d954a1 to your computer and use it in GitHub Desktop.
Save schester44/d71e02e230ee457437f6482a22d954a1 to your computer and use it in GitHub Desktop.
access nested objects by string key
function resolve(path, obj=self, separator='.') {
return (Array.isArray(path) ? path : path.split(separator)).reduce((prev, curr) => prev && prev[curr], obj)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment