Is it possible to use JavaScript to locate a property within an array that is nested within another array and return its "path"?
Visualize a hierarchical group of nested arrays similar to this example:
var bigBox = [
mediumBoxA = [
smallBoxA = [
toyA = { toyId : "Blue Ball"},
toyb = { toyId : "Pink Ball"}
],
smallBoxB = [
toyA = { toyId : "Girl Doll"},
toyB = { toyId : "Boy Doll"}
],
],
mediumBoxB = [
smallBoxA = [
toyA = { toyId : "Batman"},
toyB = { toyId : "Superman"}
],
smallBoxB = [
toyA = { toyId : "Lego"},
toyB = { toyId : "Soldier"}
],
]
];
With that setup, I aim to be able to search for something like "Batman" in the console and find out that it is located in bigBox > mediumBoxB > smallBoxA > toyA. I'm specifically looking for a solution using only JavaScript and one that can be executed in the console without involving HTML.
I understand that I could use index numbers instead of labels like "smallBox", "toyB", etc., but I included those labels for clarity purposes.
Appreciate your help!