Say I have the following object:
let exampleObj = {
hello: {
there: {
friend: 'my friend!',
neighbor: 'neighbor!',
world: 'world!'
}
}
}
Is there an efficient way I can create a function such as
function getPropValues(obj, ...keys) {
// ...
}
where if I call getPropValues with the following arguments
const result = getPropValues(exampleObj, 'hello', 'there', 'world');
It would give me the result of exampleObj['hello']['there']['world']?
(i.e. I would expect result to be 'world!' in this case)
'hello', 'there', 'world'reliably navigates to the property you want?