I have an array that contains objects that might have nth levels of depth.
Something like this:
const settings = [
{path: '/templates/pictures.php', url: '/pictures', label: 'Pictures', component: 'tab', template: 'default'},
{path: '/templates/post-article.php', url: '/user/:username', component: 'table', template: 'default', children:[
{path: '/templates/post-article-highlights.php', url: '/user/:username/highlights', component: 'table', template: 'default', children:[
{path: '/templates/post-article-highlights.php', url: '/user/:username/highlights', component: 'table', template: 'default'}
]}
]}
]
I need to push on a different array only the 'Url' property and the children property if present, preserving the depth though.
So the new array should look like this:
const newArray = [
{url: '/pictures'},
{url: '/user/:username', children:[
{url: '/user/:username/highlights', children:[
{url: '/user/:username/highlights'}
]}
]}
]
Can you help me?
Thanks