I have an array of object like this:
[
{
header: {
car: 'Start',
carName: startName
},
data: [ [Object], [Object], [Object] ]
},
{
header: {
car: 'End',
carName: endName
},
data: [ [Object], [Object], [Object] ]
},
{
header: {
car: 'Finish',
carName: finishName
},
data: [ [Object], [Object], [Object] ]
}
]
Where startName, endName, and finishName are function references. I want to replace the whole array with actually calling the function so it should be like this:
[
{
header: {
car: 'Start',
carName: startName()
},
data: [ [Object], [Object], [Object] ]
},
{
header: {
car: 'End',
carName: endName()
},
data: [ [Object], [Object], [Object] ]
},
{
header: {
car: 'Finish',
carName: finishName()
},
data: [ [Object], [Object], [Object] ]
}
]
I thought of creating some sort of mapping function and new object but looks like its too much. Is there a simpler way to do it?