How can I get the method getValueThroughPath(object, keysArray)
that works like so:
var object = {
key1: {
key2: {
key3: {
key4: "value"
}
}
}
}
getValueThroughPath(object, ['key1', 'key2', 'key3', 'key4']); // = "value" and undefined if wrong path
?
I'm also looking for the setValueThroughPath(object, keysArray)
equivalent method.
I use Lodash if this can shorten the solution.