DEV Community

Discussion on: How do you deal with null vs undefined?

Collapse
 
ncomet profile image
Nicolas Comet

When we write TypeScript apps, we tend to prefer using neither null nor undefined. We use null objects : let’s say you have a Customer to display. We use a const NoCustomer of same type to underline that there is no customer selected/in state at the moment. Leverage the power of typed languages ;)

Now you can say if(customer != NoCustomer) explicit, no doubt possible.