If you want to check for a nested property in a complex object, you can do it in a single call with lodash / underscore.
Example object:
parent: {
child1: {
child2: {
child3: {
}
}
}
}
To prevent undefined errors, you would usually check at each level:
(parent
&& parent.child1
&& parent.child1.child2
&& parent.child1.child2.child3
){
do.something()
}
Using _.has, you can reduce it to:
_.has(parent, ‘child1.child2.child3’)