Suppose I have an object like following:
var Obj = {
a: {
name: 'X',
age: 'Y',
other: {
job: 'P',
location: {
lat: XX.XXXX,
lng: YY.YYYYY,
.........
}
}
}
};
My objective: I need a method that will check existence of a key and return its immediate parent object for any level of nesting.
Example If I search for lat that method will return location object, if I search for job it will return other and so on.
Please help.
Thanks….
Try this:
Use: