Open JoshuaKGoldberg opened 2 years ago
?. and !. aren't the same. I should write an article explaining the difference.
?.
!.
One common slipup I've seen is people doing this:
const myValue = document.getElementById(someId)?.textContent;
...and wondering why myValue is string | undefined, not string.
myValue
string | undefined
string
Overview
?.
and!.
aren't the same. I should write an article explaining the difference.One common slipup I've seen is people doing this:
...and wondering why
myValue
isstring | undefined
, notstring
.