path_to_target
v1.0.0
Published
A function that traverses an object based on keys in an array and returns the value
Downloads
3
Maintainers
Readme
A simple function that traverses an object
Pass the object and the keys (as strings) and the function return the value or undefined if it doesn't exist.
const pathToTarget = require('path_to_target');
const anObject = {hello: {world: ' hello earth'}};
const result = pathToTarget(anObject, ['hello', 'world']);
console.log(result);
//'hello earth'