Is there a way to extract all the values associated with the property code
within nested arrays of objects, regardless of how deeply they are nested?
[
{code: '1', children: [
{code: '11'}, {code: '12'}
]},
{code: '2', children: [
{code: '21'}, {code: '22', children: [{code: '221'}]}
]},
]
The desired output should be : [1, 11, 12, 2, 21, 22, 221]