I have an object:
object.day.time
where I need to access the time property.
Due to the nature of the function, I only have access to the base object. I.E.
function access(property){
let item = object[property]
// Do a lot of stuff with item
}
I don't want to rewrite the function because the main use case is accessing objects one level deep. I.E. the day property. Is there any way I can make this work?
The only thing I could think of was:
property = [['day']['time']]
but that didn't work.
EDIT: I originally had object as a param to access which was wrong. I that case I could just pass object.day as a value
accessfunction, you'll have to rewrite it, at least a bit. Right now, you cannot expect to access the second level, since, as you stated, it is only designed for the main use case, which is one level object.accessthis way:access(object.day, 'time')?