Is there a better or shorthand way to perform a check on whether or not a variable within (possibly several levels of) an object is null or undefined?
What I would currently do to check is:
if (typeof json !== 'undefined' || typeof json.data !== 'undefined' || typeof json.data.formkeys !== 'undefined') {}
Is there a shorthand way to check for whether or not "json.data.formkeys" is undefined without the concern that one or all of the higher level properties or the object itself might not currently exist?
try catch
would likely solve this. Take a look here. \$\endgroup\$json
is generated from, and what you intend to do withformkeys
? \$\endgroup\$