I think that’s exactly what the nullish ?? Operator is.
You can write x ?? y
Which is x !== null and x != undefined ? x : y
Re:New ES2019 JavaScript features
by james-mcelwain on Friday September 27, 2019 @11:42AM
(#21093170)
Kotlin.
For example in PHP, it works exactly like you describe.