Abstract
- Handles situation when we try to access non-existent resources gracefully
- For example, handling Segmentation Fault by moving the error from runtime to compilation
Optional
Datatype
- A special Datatype that achieves Null Safety
- The
Optional
datatype contains either the data itself orNone
- When a programmer writing his/her codes, the Compiler will only compile if he/she handles the
Optional
explicitly - This only works on languages that support both Generics and Compilation
Safe Navigation
-
Also known as Optional Chaining
-
Provides a safe way to interact with potentially null values during runtime - when a null is encountered, the program will short-circuit and return
undefined
early
-
In Node.js, we can place
?
after the variable before accessing the value of the variable. If the variable is null, it will returnundefined
, instead of crashing -
When programmer writing his/her codes, he/she can use Linter to show codes that will lead to
undefined