this question has answer here:
i want var = b.c.d || null
but issue is, a
might undefined
, b
might be, or c
might be
so short of ugly try{} catch{}
or if
statements best way this? constructing quite large object (say 50 odd properties) 3rd party data source
var = ( b && b.c && ('d' in b.c)) ? b.c.d : null;
Comments
Post a Comment