Get the value at given path of an object
JavaScript version
const getValue = (path, obj) => path.split('.').reduce((acc, c) => acc && acc[c], obj);
Examples
getValue('a.b', { a: { b: 'Hello World' } }); // 'Hello World';
JavaScript version
const getValue = (path, obj) => path.split('.').reduce((acc, c) => acc && acc[c], obj);
Examples
getValue('a.b', { a: { b: 'Hello World' } }); // 'Hello World';