I have stuck at a point where I want to recursively traverse all the objects in an array and get the keys of those objects in a array data structure. I know how to loop over and get the keys of the object. But the problem here is I need that recursively for flexible objects. By flexible I mean it can have any level of nested properties.
So, what I have is an array like this:
let record = [{
"province": "string",
"city": "string",
"type": "alternative_address",
"address_line1": "string",
"post_code": "5858"
},
{
"province": "string",
"city": "string",
"type": "alternative_address",
"post_code": "5858",
"embedeer": {
"veryEmbedded": {
"veryveryEmbeded": 'yes'
}
}
}
];
And with some computation I am expecting an output like:
['province','city','type','address_line1','post_code','embedeer', 'embedeer.veryEmbedded', 'embedeer.veryEmbedded.veryveryEmbeded'];
For the effort I tried on this, I used the reduce() operation on array but I am unable to get that.