I don't think "nested values" is the right term, but here's what I'm trying to do:
Let's say I have an object that looks like this:
{
title: 'Foo',
content: {
top: 'Bar',
bottom: 'Baz'
}
}
And I want to check if either title or content.top or content.bottom contains a certain string.
I've found that I can loop through an object keys with something like this:
for (var property in object) {
if (object.hasOwnProperty(property)) {
// do stuff
}
}
But what if the key is an object in itself and contains other keys? What if those keys are also objects with different keys? So basically, is there a way to search the entire object in a "deep" way, so that it searches all values no matter how deep the values are "nested"?
myObject.content.top