The object structure is as follows.
object = {
obj1: {
obj2: {
name: 'MY name'
}
}
}
This structure is dynamic and sometimes there wont be an obj1.
So, In react you will be writing the code like..
object && obj1 && obj2 && obj2.name
so that only if object, obj1, and obj2 are present then obj2.name will be displayed.
In this case there wont be any undefined error since the presence of each object is checked prior to going inside the function.
Is there alternate way to the above code so that it displays the name when all the objects are present. If not, it should not throw an error.