Closed dotnetCarpenter closed 3 years ago
Hey! Thanks, only yesterday I found out that this library is mentioned in the newsletter.
What is the postfix ! for? ... Is it a typescript thing?
Yes, this is a TypeScript thing. codePointAt
can return undefined
if it doesn't find a character at that index. By appending !
we are telling TypeScript that it is safe to assume that the returned value from codePointAt
is a non-null, non-undefined value.
Try hovering over strOrNull
and onlyStr
in this TS playground to see how it works.
Hope that helps!
Thanks @ajitid!
Hi, congratz on being on javascript weekly.
I skimmed the source and found
str.split("").map((s) => s.codePointAt(0)!);
.What is the postfix
!
for? I tried to copy the line and are getting a syntax error in nodejs REPL. Is it a typescript thing?Cheers!