Let's consider a scenario in the below example, where I want to check the value of the object x.a.b
or x.a.b.c
, but it is throwing an exception while trying to access the object at second level (x.a.b
) 'Uncaught TypeError: Cannot read property 'b' of undefined'.
Ultimately I want to access x.a.b.c
, and how can I check if the value is not 'undefined' or 'null' using lodash?
Is there a way to check the object in a series of values?
var x = {}
!_.isUndefined(x); // true
!_.isUndefined(x.a); // false
!_.isUndefined(x.a.b); // Uncaught TypeError: Cannot read property 'b' of undefined