Nullish Coalescing
This lesson explains the new nullish coalescing operator.
We'll cover the following
Nullish coalescing for an object
TypeScript 3.7 brought the nullish coalescing operator: ??
. On the left side of the operator is a variable or condition. On the right side is the result if the condition is null
or undefined
.
One use case for this operator is to check if a variable is set to define a default value.
The invocation of line 19 of myFunction
does not have a second parameter. It causes the code to use the default value on line 8.
Get hands-on with 1400+ tech skills courses.