This idea could also be used to solve this particular use-case. The suggestion there is to introduce a ?
operator, that returns true
if the input value is not nullish, and false
otherwise.
You could combine this with the ternary operator to achieve the desired effect:
?expression ? expression_if_not_nullish : expression_if_nullish