In the above code, the compiler will fail if you if you try to use canBeNull without applying null checks first. In the second case, it won't because... well, it cannot be null.
Note that I explicitly set the type on the second variable though it's not necessary for better readability.
Front end developer specialising in JavaScript and React. Experienced in all aspects of modern front end development. Passionate about making accessible, secure and performant software.
In the above code, the compiler will fail if you if you try to use
canBeNull
without applyingnull
checks first. In the second case, it won't because... well, it cannot benull
.Note that I explicitly set the type on the second variable though it's not necessary for better readability.
Thanks for the clarification. I modified that section to mention non-nullable types and credited you for pointing them out.
Please let me know if you don't want the credit or if you'd rather be credited in a different way.
I didn't expect credit so that's very fine, thanks!