I am looking for a way to default a javascript value if something in an object with 3+ depth is undefined. For instance, something like this:
var finalData = {};
const data = {};
finalData.transactions = data.b.transactions || [];
instead of:
var finalData = {};
const data = {};
if (data.b)
finalData.transactions = data.b.transactions || [];
else
finalData.transactions = [];
The problem with the first line is it will fail with an undefined access issue if data does not have a child named b.