Lesson
Use the Optional Chaining Operator to Simplify Checking for Nullish Values
The Optional Chaining Operator, ?., can be used as a simple way to check if a variable has a nullish value (null or undefined). Instead of littering your app with checks like data && data.movies, you can write data?.movies instead.
- Duration
- 1 min
- Access
- Free
- Transcript
- Available
The Optional Chaining Operator, ?., can be used as a simple way to check if a variable has a nullish value (null or undefined). Instead of littering your app with checks like data && data.movies, you can write data?.movies instead.
Check out the Optional chaining MDN docs to read more about the new operator.