Consider the following object:
{
"apples": [
"one",
"two"
],
"oranges": [
"three",
"four"
]
}
If I want to find the value four
within this object, how can I do so efficiently? Would a loop work, like the one shown below?
for (var i=0; i < obj.length; i++) {
for (var y=0; y <obj.childObj.length; y++ {
obj.childObj[i] === 'four' ? return : null;
}
}
Alternatively, is there a more optimal way to organize and search through this data structure?