GitHub 6219★

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';
Follow me on and to get more useful contents.