Skip to content

Instantly share code, notes, and snippets.

@Komock
Created June 14, 2018 09:22
Show Gist options
  • Save Komock/01e25182149855e0245781068727163c to your computer and use it in GitHub Desktop.
Save Komock/01e25182149855e0245781068727163c to your computer and use it in GitHub Desktop.
Get value by string path
const some = {a: { bc: { de: 'hello'}}};
const path = 'a.bc.de';
let result = Object.assign({}, some);
path.split('.').forEach( part => {
console.log(result);
result = result[part];
});
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment