0

javascript has the same struct as PHP's associative array named Object. in PHP when we want to check if this key is set or not we can use this operator that can lead a concise code instead of using nested if blocks:

$b = $a['parentKey']['childKey']['grandChildKey'] ?? '';

that means if 'grandChildKey' and all parent keys of that key is set and has a value other than the null return that value, otherwise returns an empty string. is there any similar syntax in js?

0 Answers0