Let us consider the following array and object:
const keys = ['a', 'b', 'c'];
const object = {
a: {
b: {
c: {
data: 1
}
}
}
}
Naturally, I would access the data like so:
object['a']['b']['c']
The question is, how can I access the data using the array as input? Something like:
object[...keys]