Null and undefined

There are two values that represent the idea of a "nonexistent value" - null and undefined. While they can (for the most part) be used interchangeably, there are notable differences between them.

Loading TypeScript...

There are many situations where you want null or undefined values to evaluate to exactly false, and all other values to evaluate to true. In such situations, you can use the not operator (!) twice to effectively "double invert" a value into a boolean.

Loading TypeScript...

Was this page helpful?