Tuesday, 27 April, 2021 UTC


Summary

This lesson introduces the `??` operator which is known as [nullish coalescing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator). The `??` operator produces the value on the right-hand side if (and only if) the value on the left-hand side is `null` or `undefined`, making it a useful operator for providing fallback values. We'll contrast the `??` operator with the `||` [logical OR operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR) which produces the value on the right-hand side if the value on the left-hand side is _any_ falsy value (such as `null`, `undefined`, `false`, `""`, `0`, …). ## Additional Reading - [Nullish Coalescing: The `??` Operator in TypeScript](https://mariusschulz.com/blog/nullish-coalescing-the-operator-in-typescript) - [The `&&` and `||` Operators in JavaScript](https://mariusschulz.com/blog/the-and-and-or-operators-in-javascript)