There is a way to pass a string in a function to other function and this string is a reference to an object in this other function?
function fun1 (structure){
obj = [{"header":{"orderNumber": a, "item": 1}}, {"header":{"orderNumber": b, "item": 1}}]
newObj = obj[0].structure
console.log(newObj)
//first call a
//second call 1
}
//first call
function fun2(){
structure = 'header.orderNumber'
fun1(structure)
}
//second call
fun2(){
structure = 'header.item'
fun1(structure)
}
What I want is a dynamic way to access an object by creating a string. For example in the block of code obj.header.item.description and this is valid. I would like to pass a string in this string somehow make a reference to the object so I can get the value.