Is there a way to overload the ?
operator in Javascript to gracefully handle null or undefined.
An example use case is const userAddress = user?.address
. userAddress
is either some valid value or null/undefined
.
If this is not possible in javascript, is it possible to overload the ?
operator in any one of the languages that compile to javascript (ex. typescript).