Say I have the following object:
const myObj = {
id: 1,
children: [
{
id: 2,
children: [
{
id: 3
}
]
},
{
id: 4,
children: [
{
id: 5,
children: [
{
id: 6,
children: [
{
id: 7,
}
]
}
]
}
]
},
]
}
How can I tell how deep the object goes? For example the above object would be 4 levels deep.
I've searched SO and the only thing similar I could find was this question, but it did not work for me, and also seems very outdated.