Nullish Coalescing and Null or Undefined Operands

Learn nullish coalescing in TypeScript for default values with null or undefined variables.

Nullish coalescing

In general, it is a good idea to check that a particular variable is not either null or undefined before using it, as this can lead to errors. TypeScript allows us to use a feature of the 2020 JavaScript standard called nullish coalescing, which is a handy shorthand that will provide a default value if a variable is either null or undefined.

Get hands-on with 1200+ tech skills courses.