I have the following Array and want to access a nested element. How do I do that?
var productionSteps = [
0: {
displayName: "..."
final: ...
generateQRCode: ...
inputs: [
0: {
"asset":"ValueAsset", "amount":1000
},
1: {...},
2: {...},
3: {...},
]
},
1: {...},
2: {...},
3: {...}
]
I want to map through the "asset" inside of the input for every element of the parent Array. Therefore I want my console.log to return "ValueAsset", ... and so on.
I have tried this the following way but only reach a specific Input Array, but I want to map through all of them.
{Object.values(productionSteps).map((value: any, index) => {
return (
console.log(JSON.stringify(value.inputs[0]
))
);
})}
How would I map through the input Array to console log all of the "asset"?
I solved this the following way:
{Object.values(productionSteps).map((value: any, index) => { return ( value.inputs.map((value: any) => { return ( console.log(JSON.stringify(value.assetGroup)) ) } )) } ) }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.